5 Android 表格布局、网格布局、帧布局、绝对布局

本文详细介绍了Android中的四种布局:表格布局(TableLayout),强调了TableRow的重要性和布局特性;网格布局(GridLayout),允许自定义行列并设置组件位置;帧布局(FrameLayout),关注其前景图像属性;以及绝对布局(AbsoluteLayout),通过指定坐标定位组件。
摘要由CSDN通过智能技术生成

③表格布局(TableLayout)
表格布局就是让控件以表格的形式来排列组件的,只要将组件或信息放在单元格中,控件就可以整齐的排列。在TableLayout中,行数由TableRow对象控制的,即布局中有多少TableRow对象,就有多少行。
注:
①如果我们直接往TableLayout中添加组件的话,那么这个组件将占满一行!

<?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">
   <Button
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="a">
   </Button> 
</TableLayout>

②如果我们想一行上有多个组件的话,就要添加一个TableRow的容器,把组件都丢到里面

<?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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值