安卓基本布局(下)

TableLayout

常用属性描述
collapseColumns设置需要被隐藏的列的列号。
shrinkColumns设置允许被伸缩的列的列号。
stretchColumns设置允许被拉伸的列的列号。
<TableLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TableLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:collapseColumns="0,2"
    android:shrinkColumns="3"
    android:stretchColumns="1">
    <TableRow>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="one" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="two" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="three" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="four" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="five" />
    </TableRow>
</TableLayout>

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

FrameLayout帧布局

  这个布局直接在屏幕上开辟出一块空白的区域,当我们往里面添加控件的时候,会默认把他们放到这块区域的左上角。帧布局的大小由控件中最大的子控件决定,如果控件的大小一样大的话,那么同一时刻就只能看到最上面的那个组件,后续添加的控件会覆盖前一个。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".FrameLayoutActivity">

    <TextView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#FF6143" />
    <TextView
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:background="#7BFE00" />
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#FFFF00" />

</FrameLayout>

在这里插入图片描述

GridLayout

  与表格布局类似,但是比表格布局灵活。

常用属性描述
orientation设置排列方式。vertical:竖直(默认);horizontal:水平。
layout_gravity设置对齐方式。
rowCount设置行数。
columnCount设置列数。
layout_row设置第几行。
layout_column设置第几列。
layout_rowSpan设置横跨几行。
layout_columnSpan设置横跨列数。
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/GridLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:columnCount="5"
    android:orientation="horizontal"
    android:rowCount="5" >

    <Button
        android:layout_gravity="fill"
        android:text="1"
        android:layout_columnSpan="3"/>
    <Button
        android:layout_gravity="fill"
        android:text="2"
        android:layout_column="1"
        android:layout_rowSpan="3"/>
    <Button android:text="3" />
    <Button
        android:text="4"
        android:layout_row="2"/>
    <Button android:text="5" />
    <Button android:text="6" />
    <Button android:text="7" />
    <Button android:text="8" />
    <Button android:text="9" />

</GridLayout>

在这里插入图片描述

  • 21
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

姜君竹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值