How to get view from event coordinates in android when rotating view?

I have a method for event coordinates that relates to an internal target.

public boolean isInsideView( View view,float x, float y){ int location[] = new int[2]; view.getLocationInWindow(location); int viewX = location[0]; int viewY = location[1]; if(( x > viewX && x < (viewX + view.getWidth())) && ( y > viewY && y < (viewY + view.getHeight()))){ return true; } else { return false; } } 

But it doesn’t work when rotation is set as the viewing target.

  <ImageView android:id="@+id/v_checkpoint1_1" android:layout_width="50dp" android:layout_height="150dp" android:background="@android:color/holo_green_dark" android:rotation="-25" /> 

please help me fix this. thank you very much.

+4
source share

Source: https://habr.com/ru/post/1501734/


All Articles