Android学习笔记(一)——LinearLayout

Android小白,初次学习,笔记自用,敬请指正😛
有帮助记得一键三连呀(点赞收藏关注)😁

一,最常用属性:

android:id="@+id/标识"
android:layout_width="宽度(match_parent匹配父空间|wrap_content匹配包含内容|xxdp自定义)"
android:layout_height="高度(同上)"
android:orientation="内部布局方向(水平|垂直)"
android:background="背景颜色"
android:padding="内边距"
android:layout_margin="外边距"
android:gravity="内部组件的排列方式(center|right...)"
android:layout_weight="剩余部分的权重"

二,实例演示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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:paddingRight="20dp"
        android:paddingLeft="20dp"
        android:paddingTop="50dp"
        android:paddingBottom="10dp"
        android:gravity="top|right">

        <View
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#FF0033"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="#0066FF"
        android:orientation="horizontal"
        android:layout_margin="15dp">
        <View
            android:layout_width="10dp"
            android:layout_height="match_parent"
            android:background="#000000"
            android:layout_weight="1"/>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#FF0033"
            android:layout_weight="2"/>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#55AA99"
            android:layout_weight="2"/>

    </LinearLayout>

</LinearLayout>

三,效果图:

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值