【问题标题】:Android RecyclerView item text too longAndroid RecyclerView 项目文本太长
【发布时间】:2017-01-14 01:49:24
【问题描述】:

我有一个 RecyclerView 列表,其中某些项目(文本)对于设备允许的宽度来说太长了。我可以使用 android:ellipsize="end" 来指示文本被截断,但我希望能够向用户显示整个文本。我可以使用 android:scrollHorizo​​ntally="true" 然后文本将滚动,但没有视觉指示用户需要滚动它,并且文本看起来被截断了。这种情况下好的用户体验是什么?谢谢。

【问题讨论】:

    标签: android text scroll user-experience truncation


    【解决方案1】:

    1、你可以像这样编辑你的textView xml <TextView ... android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:text="......"/> 它会自动水平滚动,或者您可以在列表项中使用 autoFitTextView,auto fit textview

    【讨论】:

    • 谢谢,我试过选框,但它只是来回滚动,这对于列表项来说不是一个好的用户体验。
    【解决方案2】:

    您可以将android:scrollbars="horizontal" 添加到您的回收站视图以显示滚动条。

    【讨论】:

    • 谢谢,但我试过了,它不起作用(没有显示滚动条)
    【解决方案3】:

    原来解决办法是把item包裹在Horizo​​ntalScrollView中并设置android:layout_gravity="fill_horizo​​ntal"。这允许滚动,并且有一个用于长项目的水平滚动条。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-12
      • 2016-07-17
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      • 2018-11-14
      • 1970-01-01
      • 2022-12-18
      相关资源
      最近更新 更多