android – 如何对listView项使用PercenRelativeLayout

android – 如何对listView项使用PercenRelativeLayout,第1张

概述我正在尝试将PercenRelativeLayout用于ListView,但它不起作用, 高度和宽度百分比被忽略,列表视图中没有显示任何内容. 它只适用于棉花糖. 这是列表项xml <?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentRelativeLayout xmlns:android="http://s 我正在尝试将PercenrelativeLayout用于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 – 如何对listView项使用PercenRelativeLayout全部内容,希望文章能够帮你解决android – 如何对listView项使用PercenRelativeLayout所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1123739.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存