2014-12-18 7 views
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()); 
    } 
} 

답변

1

방법은 PX에서 그 값을 돌려 줄 getLeft(). 하지만 당신은 마진이 dp입니다.

android:layout_marginLeft="80dp" 
관련 문제