Android Studio布局

LinearLayout线性布局

从行开始,顶格

排列方向

android:orientation=“horizontal”

在这里插入图片描述

android:orientation=“vertical”

在这里插入图片描述

排列位置

注意layout_width和layout_height的值是match_parent还是wrap_content,因为是根据控件的边界,所以这会影响居中效果

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center">

center水平垂直居中、center_vertical垂直居中、center_horizontal水平居中、right最右、left(top)最左、bottom最下
center_vertical垂直居中、center_horizontal水平居中、right最右、left最左、bottom最下

行列权重

控件在一行/列中所占的比例

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="111"
                />
            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="222"
                />
        </LinearLayout>

在这里插入图片描述

// 换成垂直方向排列
android:orientation="horizontal"

在这里插入图片描述

相关推荐

  1. AndroidStudio

    2024-04-27 08:38:04       42 阅读
  2. AndroidStudio开发 相关依赖

    2024-04-27 08:38:04       17 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-27 08:38:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-27 08:38:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-27 08:38:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-27 08:38:04       20 阅读

热门阅读

  1. 后端开发大纲

    2024-04-27 08:38:04       19 阅读
  2. js 中整数的安全范围是多少

    2024-04-27 08:38:04       18 阅读
  3. 【OpenCV】(一)wechat_qrcode检测二维码

    2024-04-27 08:38:04       15 阅读
  4. Eureka 详解:构建高可用微服务架构

    2024-04-27 08:38:04       19 阅读
  5. spring获取controller参数过程

    2024-04-27 08:38:04       15 阅读
  6. redis 结合Lua脚本实现 秒杀、防止超卖

    2024-04-27 08:38:04       15 阅读
  7. 传感器网络关键安全技术研究的中期报告

    2024-04-27 08:38:04       13 阅读
  8. 如何在Pycharm中使用Git来进行版本管理

    2024-04-27 08:38:04       14 阅读
  9. Impala系统架构理解

    2024-04-27 08:38:04       15 阅读
  10. 机器学习学习 - 数据预处理

    2024-04-27 08:38:04       12 阅读
  11. JWT常见攻击手法

    2024-04-27 08:38:04       11 阅读