Android studio相关(2):B站‘Android架构解析’基础入门笔记——第二章布局

学习B站‘Android架构解析’【2021最新版】Android(安卓)开发零基础入门课程【全套】

(自学还是要尽量跟着视频敲一敲代码,做做笔记------如有侵权,联系我删除)

1 LinearLayout

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_gravity="center_horizontal"
    android:gravity="center_horizontal|bottom"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:layout_width="100dp"
        android:background="#ff0000"
        android:layout_height="100dp"

        android:layout_weight="5"
        />
    <LinearLayout
        android:layout_width="100dp"
        android:background="#00ff00"
        android:layout_height="100dp"
        android:layout_weight="1"
        />
    <LinearLayout
        android:layout_width="100dp"
        android:background="#0000ff"
        android:layout_height="100dp"
        android:layout_weight="1"
        />
</LinearLayout>

在这里插入图片描述

2 RelativeLayout

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <RelativeLayout
        android:id="@+id/rl1"
        android:background="#ff0000"
        android:layout_centerInParent="true"
        android:layout_width="100dp"
        android:layout_height="100dp"/>

    <RelativeLayout
        android:background="#00ff00"
        android:layout_margin="100dp"
        android:layout_width="100dp"
        android:layout_height="100dp"/>
    
</RelativeLayout>

在这里插入图片描述

3 FrameLayout

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <FrameLayout
        android:background="#ff0000"
        android:layout_width="400dp"
        android:layout_height="400dp"/>
    <FrameLayout
        android:background="#0000ff"
        android:layout_width="300dp"
        android:layout_height="300dp"/>
    <FrameLayout
        android:background="#00ff00"
        android:foreground="@drawable/tianshan"
        android:foregroundGravity="center|bottom"
        android:layout_width="200dp"
        android:layout_height="200dp"/>

</FrameLayout>

在这里插入图片描述

4 TableLayout

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:collapseColumns="0,2"
    android:stretchColumns="1"
    android:shrinkColumns="2"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TableRow>
        <Button
            android:text="第1个"
            android:layout_width="wrap_content"
            android:layout_column="2"
            android:layout_span="2"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第2个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>


    </TableRow>

    <TableRow>
        <Button
            android:text="第1个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第2个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第3个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第4个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <Button
            android:text="第5个"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>


    </TableRow>

    <Button
        android:text="第1个"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <Button
        android:text="第2个"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>




</TableLayout>

在这里插入图片描述

5 GridLayout

在这里插入图片描述
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<GridLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="第1个"/>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_row="1"
        android:layout_column="0"
        android:layout_columnSpan="3"
        android:layout_gravity="fill"
        android:text="第2个"/>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_row="0"
        android:layout_column="1"
        android:text="第3个"/>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="第4个"/>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="第5个"/>
    
</GridLayout>

在这里插入图片描述

6 ConstraintLayout

约束布局
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值