android 丢帧分析_安卓界面布局之表格布局与帧布局

TableLayout(表格布局)

Android中的表格布局与HTML中的表格标签< table >< tr >< td >相似,通过使用表格的行与列来排列组件。如果一行上有多个组件的话,就要在TableLayout中添加一个TableRow的容器,把组件都丢到里面!一个Tablerow一行,有多少列则是看TableRow中的组件个数。

常用属性

android:collapseColumns:隐藏某一列

android:shrinkColumns:允许某一列收缩

android:stretchColumns:拉伸某一列

这三个属性的列号都是从0开始计算的,如shrinkColunmns = "3",对应的是第四列,可以设置多个,用逗号隔开比如"0,3",如果是所有列都生效,用"*"号即可。

android:layout_column="3":表示的就是跳过第三个,直接显示到第四个格子处,从1开始计算。

android:layout_span="2":表示合并2个单元格,也就说这个组件占2个单元格。

看代码

<TableLayout    android:layout_width="match_parent"    android:layout_height="match_parent"    android:gravity="center_vertical"    android:stretchColumns="2"    android:shrinkColumns="1">    <TableRow        android:layout_width="match_parent"        android:layout_height="match_parent">        <Button            android:id="@+id/button7"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button1" />        <Button            android:id="@+id/button6"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button2" />        <Button            android:id="@+id/button4"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button3" />    TableRow>    <TableRow        android:layout_width="match_parent"        android:layout_height="match_parent">        <Button            android:id="@+id/button9"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button4" />        <Button            android:id="@+id/button8"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button5" />        <Button            android:id="@+id/button5"            android:layout_width="139dp"            android:layout_height="117dp"            android:text="Button6" />    TableRow>TableLayout>

效果图

982b41a1e364af69d0490a4023913066.png

FrameLayout(帧布局)

帧布局是最为简单的一种布局,该布局为每个加入其中的控件创建一个空白区域,称为一帧,每个控件占据一帧。采用帧布局时,所有控件都默认显示在屏幕左上角,并按照先后放入的顺序重叠摆放,先放入的将会在最底层,后放入的控件显示在最顶层。帧布局使用于图层设计。

属性

foreground :设置帧布局容器的前景图像

foregroundGravity :属性设置图像的显示位置

看代码

<FrameLayout    android:layout_width="match_parent"    android:layout_height="match_parent"    android:foreground="@mipmap/ic_launcher"    android:foregroundGravity="bottom">    <TextView        android:id="@+id/textView"        android:layout_width="460dp"        android:layout_height="336dp"        android:background="@color/colorAccent"        android:text="TextView" />    <TextView        android:id="@+id/textView2"        android:layout_width="332dp"        android:layout_height="242dp"        android:background="@color/colorPrimary"        android:text="TextView" />FrameLayout>

效果图

0b1faa46881f01a5565bda037d819a74.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值