gpt4 book ai didi

高度百分比的 Android 布局

转载 作者:太空狗 更新时间:2023-10-29 16:28:37 24 4
gpt4 key购买 nike

我想做这样的布局:

enter image description here

但我不知道如何让面板 2 和面板 3 以 50:50 的比例填充剩余空间(在添加固定大小的面板 1 之后)。关于 Android 布局,一定有什么我遗漏或不知道的东西,但它是什么?

我忘了说我想对这些面板使用约束布局。我使用 Android Studio。

最佳答案

使用 LinearLayout 和 layout_weight

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<View
android:layout_width="match_parent"
android:background="@color/blue"
android:layout_height="16dp" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/black"
android:layout_weight="1"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/red"/>

</LinearLayout>

Views可以改为ConstraintLayouts

关于高度百分比的 Android 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44418436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com