1
我有以下3个包装在RelativeLayout中(忽略可见性=“去”)。getLocationOnScreen返回错误的值
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_marginLeft="10dip"
android:visibility="gone"/>
<ImageView
android:id="@+id/img2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:visibility="gone"/>
<ImageView
android:id="@+id/img3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_marginLeft="60dip"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dip"
android:visibility="gone"/>
当我打电话view.getLocationOnScreen(pos);
我得到pos[0]
和219回0 pos[1]
尽管他们都不是那些(X,Y)坐标。令人费解的是,每个ImageView都给了我相同的值,特别是考虑到它们位于不同的位置。这是为什么发生?