ImageView
드로어 블 위치의 실제 위치를 찾고 싶습니다. 현재 ImageView
의 크기가 상대 레이아웃에 의해 조정되므로 0을 반환합니다. 그러나 이미지 뷰 내부의 드로어 블이 상대 레이아웃에서 모두 채워지지 않습니다. 전체 너비를 채우고, 위쪽과 아래쪽에 빈 공간이 수직으로 가운데에 배치됩니다.ImageView의 실제 위치 찾기
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative_layout_main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
>
<ImageView
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:src="@drawable/drawable"/>
</RelativeLayout>
첨부 된 스크린 샷을 참조하십시오. 나는 빨간색 사각형의 x와 y와 너비와 높이를 찾고 있습니다.
을 할 때마다 화면에 이미지의 좌표를 반환이 코드의 getBounds().. 왼쪽/오른쪽/아래/최고 값 .. ?? – Neha
일치 상위 너비와 상위가 전체 화면 너비 인 경우 0,0 또는 상위 위치 –
을 반환합니다. 시작은 0 0만이됩니다 .. ?? – Neha