Android中的TableLayout中的layout_span

Android中的TableLayout中的layout_span,第1张

概述我想为 Android应用程序创建一个登录屏幕.我正在使用TableLayout来获得正确的对齐方式.因此,两行由TextView和EditText组成,我想在它们下面添加一个宽度拉伸到屏幕的按钮.所以我将Button放在另一个TableRow中,我为Button添加了layout_span =“2”,但Button显示在第一列中. 我认为这应该是正确的,但我必须在xml文件中做错.你知道出了什么 我想为 Android应用程序创建一个登录屏幕.我正在使用tableLayout来获得正确的对齐方式.因此,两行由TextVIEw和EditText组成,我想在它们下面添加一个宽度拉伸到屏幕的按钮.所以我将button放在另一个tableRow中,我为button添加了layout_span =“2”,但button显示在第一列中.

我认为这应该是正确的,但我必须在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>

提前致谢!

解决方法 最后,我将tableLayout包装在linearLayout中,然后在tableLayout之后添加了button.
<linearLayout     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="match_parent"    androID:orIEntation="vertical" >    <tableLayout        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>    </tableLayout>    <button        androID:ID="@+ID/btnLogin"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="@string/btnLogin" /></linearLayout>
总结

以上是内存溢出为你收集整理的Android中的TableLayout中的layout_span全部内容,希望文章能够帮你解决Android中的TableLayout中的layout_span所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1136643.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存