• 线性布局和相对布局


    安卓的UI组件

    线性布局LinearLayout

    常用的属性

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nsJbBgxf-1662994885248)(C:/Users/zhengbo/%E6%88%91%E7%9A%84%E5%AD%A6%E4%B9%A0/Typora%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/%E5%AE%89%E5%8D%93/image-20220912141217404.png)]

    实例
    
    <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/zb"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:orientation="vertical"
            android:background="#000000"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:paddingTop="50dp"
            android:paddingBottom="10dp">
            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#FF0033"/>
        LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginTop="20dp"
            android:orientation="horizontal"
            android:background="#0066FF">
            <View
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:background="#FF0033"
                android:layout_weight="1"/>
            <View
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:layout_weight="1"/>
        LinearLayout>
    
    LinearLayout>
    
    • 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
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    效果展示

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2wg0KvYr-1662994885250)(C:/Users/zhengbo/%E6%88%91%E7%9A%84%E5%AD%A6%E4%B9%A0/Typora%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/%E5%AE%89%E5%8D%93/image-20220912152936252.png)]
    .

    相对布局RelativeLayout

    相对布局除了拥有线性布局所有的属性而外,他也同样有一些自己特有的属性

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cbj35Zo4-1662994885251)(C:/Users/zhengbo/%E6%88%91%E7%9A%84%E5%AD%A6%E4%B9%A0/Typora%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/%E5%AE%89%E5%8D%93/image-20220912223632767.png)]

    实例
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <View
            android:id="@+id/view_1"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="#000000" />
    
        <View
            android:id="@+id/view_2"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="#FF0000"
            android:layout_below="@id/view_1"/>
        <LinearLayout
            android:id="@+id/view_3"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_below="@id/view_2"
            android:background="#00FF00"
            android:orientation="horizontal"
            android:padding="15dp">
            <View
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:background="#FF0033"/>
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#000000"
                android:padding="15dp">
    
                <View
                    android:id="@+id/view_4"
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:background="#FF9900" />
                <View
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:id="@+id/view_5"
                    android:layout_toRightOf="@id/view_4"
                    android:background="#FFFFFF"
                    android:layout_marginLeft="15dp"/>
            RelativeLayout>
        LinearLayout>
    
    RelativeLayout>
    
    • 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
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    效果展示

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GCZcJeIL-1662994885253)(C:/Users/zhengbo/%E6%88%91%E7%9A%84%E5%AD%A6%E4%B9%A0/Typora%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/%E5%AE%89%E5%8D%93/image-20220912225821646.png)]
    .

  • 相关阅读:
    PlotNeuralNet绘制卷积神经网络结构图
    已解决module ‘keras.preprocessing.image‘ has no attribute ‘load_img‘
    2020 MIT6.s081 Lab: Multithreading
    ubuntu18.04 编译edk2项目下的intel架构bios
    稳定性总结
    Zookeeper运维
    《Java Web程序设计——开发环境搭建》
    NPM 常用命令(十)
    【开源的字典项目】【macOS】:在macOS上能打开mdd and mdx 的github开源项目
    事件抽取(and 检测)经典论文
  • 原文地址:https://blog.csdn.net/weixin_45809829/article/details/126824480