• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps how to draw a view in click position

hi there
i want to show a view in a position that user click
how to do it?
here is my code:

Code:
public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
         super.onTouchEvent(event);
        
         ImageView iv = new ImageView(this);
         iv.setVisibility(View.VISIBLE);
         iv.setImageResource(R.drawable.glass);     
         ((RelativeLayout) findViewById(R.id.container)).addView(iv);

         return true;
    }

thanks a lot
 
Last edited:
Hi,
I am not sure if this will help you. I am considering on this way.
Put RelativeLayout as main layout. Then you should get coordinates of user's click and when you will have this just add view on the RelativeLayout regarding of coordinates.

Hope that I've directed you on right way

best regards.
 
hi mango
thanks for your help
my problem solved, im so sorry to forget update this post
at this time i dont have my codes to update the result

thanks agaiin
 
Back
Top Bottom