2

使用できる要素を使用して、要素を他の要素に対して位置合わせします。

android:layout_alignLeft等..

しかし、マージンまたはパディングを追加する方法:

<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>

2番目のトップのパディングTextViewは効果がありません。

4

1 に答える 1

1

パディングとマージンが混同されているようです。TextView2番目を次のように変更します。

layout_marginTop="30dp" 

それ以外の

paddingTop="30dp".

パディングはViewそれ自体をパッドし、それを大きくします。マージンは、TextViewコンテナ内の位置を変更し(RelativeLayout)、サイズを変更しません。

于 2013-01-06T07:26:10.317 に答える