十三、TableLayout 表格布局

一、TableLayout 需要和 TableRow搭配使用

二、基本属性

android:collapseColumns 设置需要被隐藏的列的序号,从0开始

android:stretchColumns 设置允许被拉伸的列的列序号,从0开始

android:shrinkColumns 设置允许被收缩的列的列序号,从0开始

子控件设置属性

android:layout_column 显示在第几列

android:layout_span 横向跨n列 ‘

三、代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TableRow>
        <Button
            android:layout_column="1"
            android:layout_span="2"
            android:text="第1个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第2个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </TableRow>
    <TableRow>
        <Button
            android:text="第1个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第2个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第3个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </TableRow>
 
    <Button
          android:text="第1个"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/>
    <Button
        android:text="第1个"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</TableLayout>

  四、效果图

 

posted @   搬砖工具人  阅读(66)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示