android - 将此 LinearLayout 转换为约束布局
问题描述
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:layout_weight="1.0"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_green_light"
android:layout_weight="1.0"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_light"
android:layout_weight="1.0"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_light"
android:layout_weight="1.0"
android:text="Button" />
</LinearLayout>
</LinearLayout>
是否可以通过约束布局来做到这一点? 我想实现类似的东西,这在另一个问题中已经被问过,但是由于使用这种布局,我的视图在较小的屏幕设备中被削减,并且使用重量对性能不利。
解决方案
推荐阅读
- jenkins - 如何限制 Jenkins 用户使用 Jenkins RoleBasedAuthorizationStrategy 进行生产部署?
- c# - 在 Entity Framework Core 中为没有显式外键的表添加自定义导航属性
- kotlin - 在 Kotlin 中,如何创建一个 lambda 列表,其中每个 lambda 的类型为 (Int) -> List?我收到解构声明错误
- mongodb - 向数组中添加元素,如果存在则不添加,如果存在则更新
- java - 使用 Jackson 将嵌套 JSON 对象的布尔值转换为 Map 的改进方法
- jenkins - 将 JENKINS_HOME 更改为另一个硬盘
- c# - 如何使用 json 正文发送 GET 请求?
- .net-core - 无法在 .net 核心中创建/激活贝宝计划
- codenameone - 最新的 Codenameone 构建版本是否失去了滚动浏览包含 URLImages 的行容器的功能?
- html - 引导程序3的表单元素对齐问题