android(6大布局)

LinearLayout(线性布局)
在这里插入图片描述
RelativeLayout(相对布局)
在这里插入图片描述
TableLayout(表格布局)
在这里插入图片描述
FrameLayout(帧布局)
FrameLayout的属性很少就两个,但是在说之前我们先介绍一个东西:
前景图像:永远处于帧布局最上面,直接面对用户的图像,就是不会被覆盖的图片。
两个属性:
android:foreground:*设置改帧布局容器的前景图像
android:foregroundGravity:设置前景图像显示的位置

GridLayout(网格布局)
在这里插入图片描述

AbsoluteLayout(绝对布局)
1.四大控制属性(单位都是dp):
①控制大小: android:layout_width:组件宽度 android:layout_height:组件高度 ②控制位置: android:layout_x:设置组件的X坐标 android:layout_y:设置组件的Y坐标

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
好的,下面给出每种布局的一个简单实例: 1. 线性布局(LinearLayout) ```xml <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hello" android:textSize="20sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="World" android:textSize="20sp" /> </LinearLayout> ``` 2. 相对布局(RelativeLayout) ```xml <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello" android:textSize="20sp" /> <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="World" android:textSize="20sp" android:layout_below="@id/text1" android:layout_alignParentRight="true" /> </RelativeLayout> ``` 3. 帧布局(FrameLayout) ```xml <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/image1" android:scaleType="centerCrop" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello" android:textSize="20sp" android:layout_gravity="center" /> </FrameLayout> ``` 4. 表格布局(TableLayout) ```xml <TableLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Name" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter your name" /> </TableRow> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Age" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter your age" /> </TableRow> </TableLayout> ``` 5. 网格布局(GridLayout) ```xml <GridLayout android:layout_width="match_parent" android:layout_height="match_parent" android:rowCount="3" android:columnCount="3"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="1" android:textSize="20sp" android:layout_row="0" android:layout_column="0" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="2" android:textSize="20sp" android:layout_row="0" android:layout_column="1" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="3" android:textSize="20sp" android:layout_row="0" android:layout_column="2" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="4" android:textSize="20sp" android:layout_row="1" android:layout_column="0" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="5" android:textSize="20sp" android:layout_row="1" android:layout_column="1" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="6" android:textSize="20sp" android:layout_row="1" android:layout_column="2" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="7" android:textSize="20sp" android:layout_row="2" android:layout_column="0" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="8" android:textSize="20sp" android:layout_row="2" android:layout_column="1" android:layout_columnWeight="1" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:text="9" android:textSize="20sp" android:layout_row="2" android:layout_column="2" android:layout_columnWeight="1" /> </GridLayout> ``` 以上是五种布局的简单实例,开发者可以根据具体需求进行修改和调整。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值