0
我正在將自定義視圖加載到線性佈局中。自定義視圖包含可以放置在線性佈局中的圖像。如何確定圖像定位後哪些像素可見?在自定義視圖中查找圖像位置
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/viewPort"
android:orientation="horizontal"
android:layout_width="700dp"
android:layout_height="200dp">
</LinearLayout>
</RelativeLayout>
而且我的代碼加載圖像:加載視圖
View touchView = new TouchViewClass(this,mPicturePath);
LinearLayout rl = (LinearLayout)this.findViewById(R.id.viewPort);
rl.addView(touchView);
你想要視圖的x和y座標? – Naddy
我需要視圖內圖像的x和y座標。一旦位圖被繪製到畫布上,它可以在佈局中移動。我需要找到相對於佈局的x和y,以便我可以確定哪些部分正在查看。 – TheGeekNess