我想查找ImageView
drawable的實際位置。目前它返回0,因爲ImageView
被相對佈局調整大小。但是圖像視圖中的drawable並不是全部填充在相對佈局中。它填滿了整個寬度,並且它的頂部和底部都有空的空間。查找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以及它的寬度和高度。
難道ü嘗試的imageView.getDrawable()你在屏幕上的座標圖像的getBounds()。左/右/底/頂值.. ?? – Neha
它返回0,0或父位置 –
如果它的匹配父寬度和父母是全屏幕的寬度開始將只有0 0 .. ?? – Neha