2012-04-30 1 views
9

나는 다음과 레이아웃 파일이 있습니다 (I 실제 장치에서 테스트했습니다 그것은 같은 모양) 에뮬레이터에wrap_content를 사용할 때 layout_marginBottom이 무시되는 이유는 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#FF0000" > 

<RelativeLayout 
    android:id="@+id/usericon_img" 
    android:layout_width="73.3334dp" 
    android:layout_height="70.6667dp" 
    android:layout_marginBottom="2.6667dp" 
    android:layout_marginLeft="3.3334dp" 
    android:layout_marginTop="2.6667dp" 
    android:background="#FFFFFF" /> 
</RelativeLayout> 

를 레이아웃은 다음과 같습니다 enter image description here

내 질문은 : 왜 흰색 레이아웃 아래에 빨간 여백이 없습니까?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="76dp" 
android:background="#FF0000" > 

내가 원하는 것을 얻을 수 있습니다,하지만하지 않는 이유 wrap_content가 제대로 작동 : 나는에 외부 레이아웃을 변경하면 알아? documentation에서

답변

6

:

그 치수를 측정하기 위해이 도면 고려 패딩 걸린다.

내가 잘못하지 않는다면 여백이 치수에 추가되지 않는다는 의미입니다. 이는 wrap_content가 올바르게 작동하지만 여백을 고려하지 않음을 의미합니다.

간단한 질문 : 왜 70.6667dp과 같은 값을 사용합니까?

+0

hdpi 화면에서 106 픽셀 크기를 원하기 때문에 70.6667을 사용했습니다. – Toorop

+0

여백을 무시하는 경우 왜 왼쪽 및 위쪽 여백이 있습니까? – Toorop

+1

패딩 대신 사용해보기 – Ahmad