当前位置: 移动技术网 > 移动技术>移动开发>Android > Android学习笔记之——UI组件/LinearLayout(线性布局)

Android学习笔记之——UI组件/LinearLayout(线性布局)

2020年07月08日  | 移动技术网移动技术  | 我要评论

LinearLayout(线性布局)
最常用属性
android:id
android:layout_width
android:layout_height
android:orientation
android:background
android:layout_padding
android:layout_margin

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/ll_1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:orientation="vertical"
        android:background="#000000"
        android:padding="20dp">
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FF0033">

        </View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="horizontal"
        android:background="#0066FF"
        android:layout_margin="15dp"
        >
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#ff9900"
            android:layout_weight="1"></View>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#440033"
            android:layout_weight="1"></View>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#446633"
            android:layout_weight="2"></View> //layout_weight是权重
    </LinearLayout>

</LinearLayout>

完成效果

本文地址:https://blog.csdn.net/weixin_43561635/article/details/107189096

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网