前言
正常的xml的用法,然后就是一个标签代表着一行
一行里面可以写多个控件,其中
android:stretchColumns = “n” 这个属性代表着第n+1列会匹配剩余空间
一个实例为证:
xml文件为:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns = "1" >
<TableRow>
<TextView
android:layout_height ="wrap_content"
android:text="Account:"/>
<EditText
android:id="@+id/account"
android:layout_height="wrap_content"
android:hint = "Input your account"
/>
</TableRow>
<TableRow>
<TextView
android:layout_height ="wrap_content"
android:text="Password:"/>
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:inputType = "textPassword"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/login"
android:layout_height="wrap_content"
android:layout_span ="2"
android:text = "Login"/>
</TableRow>
</TableLayout>
实例图:(明天传)