2013-01-06 3 views
1

다른 요소와 관련하여 요소를 정렬하려면 해당 요소를 사용할 수 있습니다.안드로이드 - 부모 요소에 상대적으로 요소 + 마진 맞추기

android:layout_alignLeft

하지만 어떻게 마진이나 패딩 추가하는 방법 : 두 번째 TextView

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="5dp" > 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:text="@string/students" 
     android:textSize="30sp" 
     android:typeface="normal" 
     android:layout_marginTop="10dp" 
     android:paddingTop="5dp" 
     android:paddingBottom="5dp" 
     android:id="@+id/student" />  

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@id/student" 
     android:paddingLeft="20dp" 
     android:paddingTop="30dp" 
     android:text="@string/stud_describe" 
     android:textSize="10sp" 
     android:textStyle="italic" 
     android:typeface="sans" /> 
</RelativeLayout> 

패딩 정상은 어떤 영향을하지 않습니다.

답변

1

패딩과 마진이 섞여있는 것처럼 보입니다. 그것은 더 큰 만들기,

layout_marginTop="30dp" 

대신 패딩 패드 View 자체

paddingTop="30dp". 

의 :에 두 번째 TextView 변경합니다. 여백은 해당 컨테이너 ( RelativeLayout) 내의 TextView 위치를 변경하고 크기를 변경하지 않습니다.

+1

예, 패딩을 추가하면 textview 상단과 텍스트의 내부 부분 사이에 b = 패딩이 생깁니다. 반면 여백은 텍스트 뷰의 위쪽과 위쪽의 항목 사이에 공백을줍니다. 아웃 배치 할 때 무엇을하는지 쉽게 볼 수있는 방법은 텍스트 뷰에 배경색을 지정하는 것입니다. – WallMobile

관련 문제