十、LinearLayout 布局

常用属性

1. orientation布局中组件的排列方式

2. gravity控制组件所包含的子元素的对齐方式,可多个组合

3. layout_gravity控制该组件在父容器里的对其方式

4. background 为该组件设置一个背景图片,或者是直接用颜色覆盖

5. divider分割线

6. showDividers设置分割线所在的位置, none(), beginning(开始), end(结束), middle(每两个组件间)

7. dividerPadding 设置分割线的 padding

8. layout_weight(权重)该属性是用来等比例的划分区域 

代码详情

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
 
    <LinearLayout
        android:background="#ffff0000"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:layout_weight="2">
    </LinearLayout>
 
    <View
        android:background="#ff00ff00"
        android:layout_width="match_parent"
        android:layout_height="1dp"/>
 
    <LinearLayout
        android:background="#ff00ff00"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>
 
    <LinearLayout
        android:background="#ff0000ff"
        android:layout_width="200dp"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>
 
 
</LinearLayout>

  效果图

 

posted @   搬砖工具人  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示