FrameLayout(帧布局)

本文介绍了Android中的四种布局:LinearLayout的水平垂直排列及weight属性应用,RelativeLayout的相对定位原理,FrameLayout的重叠摆放特性,以及TableLayout的表格布局与列操作。
摘要由CSDN通过智能技术生成

在这里插入图片描述

如果将orientation的vertical设置成horizontal则会变成水平排列,如下图显示

在这里插入图片描述

可以使用layout_weight属性来设置每行控件的相对大小

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:orientation=“horizontal” android:layout_width=“match_parent”

android:layout_height=“wrap_content”>

<Button

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:text=“按钮1”/>

<Button

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:text=“按钮2”/>

<Button

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:text=“按钮3”/>

在这里插入图片描述

在layout_weight中我们设置它的占据权重为1,则总的权重为1+1+1=3,所以每个控件的所占大小就会是1/3,就会平均分掉这一行的布局。那当我们将其中一个控件的权重修改为2时,就会显示下图的结果。他们的权重比就会是1/4、1/4、2/4。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值