我需要創建類似這樣的layout
但尚未完善。在相對佈局中創建佈局
得到這個
需要這樣
我創建這個使用RelativeLayout
,需要在此只爲打造。我能夠使用Linearlayout
子佈局創建,但可以這樣無需使用任何子佈局
這是我的代碼
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="15dp">
<TextView android:text="Title" android:textColor="#ffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:id="@+id/title_add_txt"/>
<EditText android:hint="Address Title" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address_title" android:layout_toRightOf="@id/title_add_txt"/>
<TextView android:text="Address" android:textColor="#ffffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:layout_below="@id/title_add_txt"
android:id="@+id/address_txt"/>
<EditText android:hint="Address" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address" android:layout_below="@id/address_title" android:layout_toRightOf="@id/address_txt"/>
</RelativeLayout>
我不知道你爲什麼不使用Tablelayout對於這種情況,但如果你要使用的RelativeLayout,嘗試使用Android打:paddingTop或Android:paddingBottom來了TextView ... – Ahmed 2011-12-22 14:48:34