<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
<TextView
android:layout_weight="1" //当使用weight属性时,将width设为0dip即可,效果跟设成wrap_content是一样的。这样weight就可以理解为占比了!
android:gravity="center" //android:gravity限定它里面的内容要垂直居中显示 //android:layout_gravity="center_vertical",这个是指它的位置是相对于它父亲的垂直居中
android:layout_width="0dp" //如果要用比重布局,通常android:layout_width属性就会不起作用,设置为"0";根据想要布局的比例,设定android:layout_weight的值,值越大,占的布局就越大
android:layout_height="wrap_content"
android:text="姓名"
></TextView>
<TextView
android:layout_weight="2"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="李百成"
></TextView>
></TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
<TextView
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="性别"
></TextView>
<TextView
android:layout_weight="2"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="男"
></TextView>
></TableRow>
</TableLayout>
表格布局
最新推荐文章于 2021-12-20 14:31:28 发布