I'm not sure if Cristianβs suggestion of using dispatchTouchEvent() is good, this method makes sense in the descendants of ViewGroup to send touch events to their children. However, its recommendation is to use a custom view in an xml layout declaration. You do it like this:
<package.that.contains.targetenter.imageView1 android:id ....
that is, you need to specify the complete package in your own ImageView class (btw, in Java there is an agreement on using a capital letter for class names: imageView1 -> ImageView1 ). You just need to use it if you would use ImageView , and I think you will have to make it public or it is better to declare it in another file.
To call your onDraw() method, you need to call invalidate() , as Veeresh suggests, so that your imageView1 redraws. But you have to call it super, or you only get circles:
@Override public void onDraw(Canvas canvas){ super.onDraw(canvas); canvas.drawCircle(x,y,10, null ); }
If you still have problems, it may be helpful to see your targetenter.xml layout.
source share