您的位置:首页 > 房产 > 家装 > 安卓基本布局(下)

安卓基本布局(下)

2024/10/6 16:27:08 来源:https://blog.csdn.net/qq_47658735/article/details/140898085  浏览:    关键词:安卓基本布局(下)

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><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="one" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="two" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="three" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="four" /><Buttonandroid: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"><TextViewandroid:layout_width="200dp"android:layout_height="200dp"android:background="#FF6143" /><TextViewandroid:layout_width="150dp"android:layout_height="150dp"android:background="#7BFE00" /><TextViewandroid: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" ><Buttonandroid:layout_gravity="fill"android:text="1"android:layout_columnSpan="3"/><Buttonandroid:layout_gravity="fill"android:text="2"android:layout_column="1"android:layout_rowSpan="3"/><Button android:text="3" /><Buttonandroid: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>

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com