0
我試圖通過getLeft()方法在代碼中打印ImageView的位置,只是爲了查看它是否返回正確的值(它是80),並且logcat返回了192個。getLeft()返回錯誤的值
ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image1"
android:layout_gravity="center_horizontal"
android:src="@drawable/image1"
android:layout_marginLeft="80dp"/>
打印命令:
public void onWindowFocusChanged (boolean hasFocus){
super.onWindowFocusChanged(hasFocus);
if(hasFocus){
a = (ImageView)findViewById(R.id.image1);
Log.v(LOGS, "image a = " + a.getLeft());
}
}