我想为

Android应用程序创建一个登录屏幕.我正在使用TableLayout来获得正确的对齐方式.因此,两行由TextView和EditText组成,我想在它们下面添加一个宽度拉伸到屏幕的按钮.所以我将Button放在另一个TableRow中,我为Button添加了layout_span =“2”,但Button显示在第一列中.

我认为这应该是正确的,但我必须在xml文件中做错.你知道出了什么问题吗?

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

android:layout_width="match_parent"

android:layout_height="wrap_content" >

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

android:id="@+id/username"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="text" />

android:layout_width="match_parent"

android:layout_height="wrap_content" >

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

android:id="@+id/password"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="textPassword" />

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:id="@+id/btnLogin"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_span="2"

android:text="@string/btnLogin" />

提前致谢!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐