gpt4 book ai didi

Android线性布局反转

转载 作者:行者123 更新时间:2023-11-29 00:18:59 25 4
gpt4 key购买 nike

我遇到了线性布局的奇怪行为。它显示布局,就好像权重被反转一样。

这是布局:

<?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="horizontal"
android:weightSum="5">

<View
android:id="@+id/holder_list_lines"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:background="@android:color/black" >

</View>

<View
android:id="@+id/holder_list_added_lines"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/holo_orange_light" >

</View>

</LinearLayout>

然而,黑色 View 占用的空间与权重为 1 时一样多。但是权重为 4,所以出现了问题。还有一件更奇怪的事情。在图形布局模式下,此布局正确显示,重量仅在设备(Asus ME302C)上显示时反转。

最佳答案

删除权重和并保留 View 的权重

关于Android线性布局反转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24322877/

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