android – Horizo​​ntal RecyclerView wrap_content在samsungs上运行不正常?

android – Horizo​​ntal RecyclerView wrap_content在samsungs上运行不正常?,第1张

概述TL; DR – 我正在使用每个单元格上具有wrap_content宽度的水平回收器视图,并且除了三星设备之外,它正在按预期工作. 我的list_item.xml: <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" TL; DR – 我正在使用每个单元格上具有wrap_content宽度的水平回收器视图,并且除了三星设备之外,它正在按预期工作.

我的List_item.xml:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"        xmlns:tools="http://schemas.androID.com/tools"        androID:ID="@+ID/scope_layout"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:background="@drawable/bg_scope_state_normal"        androID:clickable="true"        androID:focusable="true"        androID:padding="8dp"        androID:paddingStart="16dp"        androID:paddingEnd="16dp"        androID:layout_marginStart="6dp"        androID:layout_marginEnd="6dp">    <TextVIEw        androID:ID="@+ID/scope_text"        androID:layout_centerInParent="true"        androID:background="?attr/selectableItemBackground"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:textSize="16sp"        tools:text="2/2017"/></relativeLayout>

现在,这是使用此代码在samsung s3上的外观:

如果我将List_item.xml中相对布局的宽度更改为80dp,这就是它的样子:

现在,正如你可以看到文本有不同的宽度和固定的宽度我在长字中缺少字母,wrap_content应根据文本视图宽度设置宽度,但在samsungs这不起作用,它只是拉伸布局我错过了什么吗?

解决方法 您可以在注释中删除Eugen所说的包装relativeLayout,并使用recyclelervIEw的内部系统 ItemDecorator代替绘制漂亮的背景.
这应该修复你的用户界面

此外,您可以使用Android Monitor转储视图层次结构,并查看S3的实际值

总结

以上是内存溢出为你收集整理的android – Horizo​​ntal RecyclerView wrap_content在samsungs上运行不正常?全部内容,希望文章能够帮你解决android – Horizo​​ntal RecyclerView wrap_content在samsungs上运行不正常?所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存