如何使用Android中的表行垂直对齐textview字段

如何使用Android中的表行垂直对齐textview字段,第1张

概述我有这个输出http://www.cubixshade.com/images/align_row.jpg我想要第一个字段是日期字段垂直对齐中心?我应该用什么来在其他领域左右添加一些空间呢?解决方法:您可以将android:gravity=“center_vertical”属性设置为TableRow,以使其子项垂直居中.你也可以使用android:layout_ma

我有这个输出

http://www.cubixshade.com/images/align_row.jpg

我想要第一个字段是日期字段垂直对齐中心?
我应该用什么来在其他领域左右添加一些空间呢?

解决方法:

您可以将androID:gravity =“center_vertical”属性设置为tableRow,以使其子项垂直居中.

你也可以使用androID:layout_marginleft属性或androID:layout_marginRiight属性来左右放置一些边距,你可以使用androID:layout_margintop或androID:layout_marginBottom将边距放到顶部和底部.

如果要拉伸列,则可以使用androID:layout_weight属性来定义列的权重.

作为参考,您可以看到以下带有2列的示例

<?xml version="1.0" enCoding="utf-8"?><tableLayout    xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/tableLayout01"    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:stretchColumns="1" >    <tableRow    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:gravity="center_vertical" >    <TextVIEw        androID:ID="@+ID/TextVIEw01"        androID:layout_wIDth="0dip"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:text="Male"        androID:textAppearance="?androID:attr/textAppearanceMedium" />    <EditText        androID:ID="@+ID/etNoOfMale"        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"         androID:inputType="number"/>    </tableRow>    <tableRow    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:gravity="center_vertical" >    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:text="Female"        androID:textAppearance="?androID:attr/textAppearanceMedium" />    <EditText        androID:ID="@+ID/etNoOfFemale"        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"         androID:inputType="number"/>    </tableRow></tableLayout>
总结

以上是内存溢出为你收集整理的如何使用Android中的表行垂直对齐textview字段全部内容,希望文章能够帮你解决如何使用Android中的表行垂直对齐textview字段所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/web/1115542.html

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

发表评论

登录后才能评论

评论列表(0条)

保存