I am doing this when clicked on View I am trying to get co-ordinate of the click on the view. Now I am getting value in world co-oridates I want to get it in local View co-ordinates
check the code below
public void objectClick(View objectClicked)
{
int [] locationOfViewInWindow=new int[2];
int Object = objectClicked.getId();
View img= (View)findViewById(Object);
objectClicked.getLocationInWindow(locationOfViewInWindow);
Log.d("Check:","locn in window" + locationOfViewInWindow[0]+ " "+ locationOfViewInWindow[1]);
switch (hObject) {
case R.id.imageView1:
case R.id.imageView2:......
case.R.id.imageview11:
ImageView drawable= (ImageView)findViewById(objectClicked.getId());
Drawable d = drawable.getDrawable();
boolean flag = d.getTransparentRegion().contains(locationOfViewInWindow[0], locationOfViewInWindow[1]);
Log.d("Check", "Opacity" + flag);
boolean flag is returning me null because the region of transparent it is checking w.r.t to world co-ordinate
Suggestion is appreciated
You should extend the View class for you objects and use onTouchEvent to get the click position:
}
You can use event.getX() and event.getY() to get the position of the touch event.