我想創建一個登錄屏幕的Android應用程序。我正在使用TableLayout
以獲得正確的對齊方式。因此,兩行由一個TextView
和EditText
的,我想補充低於他們Button
該寬度拉伸到屏幕上。所以我把Button
在另一個TableRow
和我說layout_span="2"
爲Button
,但Button
顯示在第一列。layout_span在TableLayout在Android的
我想這應該是正確的,但我必須做一些錯誤的XML文件。你知道什麼是錯的嗎?
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".LoginActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="15dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/evUsername" />
<EditText
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="15dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/evPassword" />
<EditText
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textPassword" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="@string/btnLogin" />
</TableRow>
</TableLayout>
在此先感謝!