Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Horizo​​ntal RecyclerView wrap_content在samsungs上运行不正常?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
TL; DR – 我正在使用每个单元格上具有wrap_content宽度的水平回收器视图,并且除了三星设备之外,它正在按预期工作.

我的list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://scheR_531_11845@as.android.com/apk/res/android"
        xmlns:tools="http://scheR_531_11845@as.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>@H_618_10@ 
 

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

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

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

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

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

解决方法

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

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

大佬总结

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

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。