首页 资讯 IT 互联网 手机 智造 家电 电商 科普 游戏 关于我们 网站地图
首页/消费电子

1

TableLayout布局标签的一个特有属性Stretchcolumns
2021-06-23

stretchColumns是TableLayout布局标签的一个特有属性,用来设置TableLayout的子标签TableRow的某列是否拉伸占满剩余的空间。例如:TableRow相当html中table的tr标签,TableRow中有两个按钮button(相当两个列td)一行显示,假如此时TableRow的宽度是700px,每个button长度是50px,那么这一行的右边600px是空的,所为了让这行铺满,就得使用android:stretchColumns。


     android:stretchColumns="*"代表TableRow中的每一列都平均拉长铺满一行(每个td宽度一样)
     android:stretchColumns="0"代表TableRow中的每第一列拉长铺满一行
     android:stretchColumns="1"代表TableRow中的每第二列拉长铺满一行
     android:stretchColumns="0,1"代表TableRow中的每第一列和第二列平均拉长铺满一行
     TableLayout的基本使用方法:
     < ?xml version="1.0" encoding="utf-8"?>
     <TableLayout xmlns:android="
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
>
<TableRow>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:layout_column="0"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button2"
android:layout_column="1"/>
</TableRow>
</TableLayout>

声明:该文系信息发布,IT手机世界仅提供信息存储空间服务。
点赞
来源:
新品快讯更多
厂商动态更多
会展中心更多
热搜排行更多

CopyRight@2015-2023 IT手机世界 All Right Reserved

工信备案号:京备A2-2009413

IT手机世界畅享移动互联时代智能智慧新生活