티스토리 뷰
화면상에 View가 그려지게 되면, 그 크기를 구할수가 있게 된다.
이 부분들은 두가지로 구분이 되게 되는데, 다음과 같다.
1. parent에 대한 자신의 위치 (상대위치)
- getLeft(), getRight(), getTop(), getBottom()
- 그냥 단순하게 위의 네가지 함수를 사용하면 구할수 있게 된다.
2. 화면상의 자신의 위치 (절대위치)
- getLocationOnScreen()
- 사용방법
int[] location = new int[2];
view.getLocationOnScreen(location);
3. 응용
- touch event가 해당 view에서 발생하였는지 알아내는 방법.
public boolean isTouchInside(View view, int x, int y) { int[] location = new int[2]; view.getLocationOnScreen(location); final int realRight = location[0] + view.getWidth(); final int realBottom = location[1] + view.getHeight(); final boolean result = (x >= location[0] && x <= realRight && y >= location[1] && realBottom); return result; }
'Mobile > Android' 카테고리의 다른 글
[Android]Log - level (0) | 2014.11.26 |
---|---|
[Android]Intent - Binder의 용량의 제한 (0) | 2014.11.25 |
[Android]dx tool - jar to dex (0) | 2014.11.21 |
[Android]adb - download file (0) | 2014.11.19 |
[Android]adb - 무선연결 (0) | 2014.11.16 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- android
- centos8
- tomcat
- Codable
- Spring
- php
- docker
- golang
- ubuntu
- war
- Linux
- SWIFT
- Xcode
- Kotlin
- intellij
- Java
- Gradle
- git
- cocoapods
- CentOS
- enum
- Windows
- rxswift
- nodejs
- ios
- MySQL
- github
- go
- windows10
- Python
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함