티스토리 뷰

View 절대 좌표값 구하는 방법


View.getLocatioinOnScreen(int[]);

위와 같은 함수를 사용하면 전체 스크린상의 절대 위치의 좌표를 구할수 있다.

예시로 아래와 같이 사용하면 된다.


 public boolean chkTouchInside(View view, int x, int y) {
 int[] location = new int[2];
 view.getLocationOnScreen(location);
 if (x >= location[0]) {
  if (x <= location[0] + view.getWidth()) {
   if (y >= location[1]) {
    if (y <= location[1] + view.getHeight()) {
     return true;
    }
   }
  }
 }
 return false;
} 


댓글

파트너스 활동을 통해 일정액의 수수료를 제공받을 수 있음



Total
Today
Yesterday
최근에 달린 댓글