Thứ Ba, 29 tháng 1, 2013

Sử dụng relative layout
khi sử dụng relative layout thì sẽ có thêm các thuộc tính hay dùng như
android:layout_toRightof("[id của button]"); đặt ở bên phải
android:layout_marginLeft="40dp"; cách bên trái 40dp


<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" >

        <TextView
            android:id="@+id/tvTemperature"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/temp" />

        <TextView
            android:id="@+id/tvHumidity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/tvTemperature"
            android:text="@string/hum"
            android:layout_marginLeft="40dp" />

        <TextView
            android:id="@+id/tvCondition"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/tvHumidity"
            android:text="@string/cond"
            android:layout_marginLeft="40dp"/>
    </RelativeLayout>

scr:https://www.youtube.com/watch?v=gCsyiHjP1P0

2 nhận xét: