gpt4 book ai didi

android - 如何将 PercenRelativeLayout 用于 listView 项目

转载 作者:太空宇宙 更新时间:2023-11-03 11:04:13 25 4
gpt4 key购买 nike

我正在尝试将 PercenRelativeLayout 用于 ListView, 但它不起作用,高度和宽度百分比被忽略, ListView 中没有显示任何内容。它仅适用于棉花糖

这里是列表项xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:background="#d20404"
android:id="@+id/test_image_id"
android:layout_width="match_parent"
android:layout_height="300dp" />

<TextView
android:background="#000"
android:text="sfgfashdsfg"
android:layout_below="@+id/test_image_id"
app:layout_heightPercent="50%"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</android.support.percent.PercentRelativeLayout>

我在 github 上有一个示例项目

最佳答案

我已经把这个问题打开给谷歌了。 答案是

The height of your ListView row item is insufficiently specified.

The first child says it wants to take 60% of the row height (note that this is heightPercent and not aspectRatio), and the second child says it wants to take 10% of the row height. But nothing tells ListView how tall the entire row wants to be. So it ends up being with height 0.

Note that the semantics of height=match_parent do not work in ListView rows, and if this works in any one particular Android platform version (for however much you can say it works), it is purely incidental.

https://code.google.com/p/android/issues/detail?id=202479

关于android - 如何将 PercenRelativeLayout 用于 listView 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35776335/

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