【问题标题】:RecyclerView items with big empty space v25.2.0RecyclerView 大空白项目 v25.2.0
【发布时间】:2017-03-05 10:18:36
【问题描述】:

我在这里阅读了很多关于 23.2.0 之后 RecycerView 更改的帖子,但是我仍然面临着我的回收站视图中的巨大空白。我在 GitHub 上创建了一个小项目来演示这个问题:https://github.com/nathan-ca/TrialRecycler

截图如下:

我使用线边框在项目周围绘制,它的大小几乎是屏幕高度的两倍。在 list_item.xml 中,如果我将 layout_height 更改为固定值,例如“100dp”,回收站视图将正确显示项目。如果我更改为 match_parent,则高度与窗口相同。当我使用 wrap_content 时,高度是窗口的两倍!所有在线帖子都说如果我使用“wrap_content”它应该会很好用。拼命不知道问题出在哪里。

【问题讨论】:

    标签: android android-recyclerview


    【解决方案1】:

    我看到你的代码并意识到你没有修复 layout_heightImageView,尝试将其修复为 60dp

    <ImageView
        android:id="@+id/item_image"
        android:layout_width="60dp"
        android:layout_height="wrap_content"
        />
    

    【讨论】:

    • 感谢您的建议。我解决了这个问题,请参阅下面发布的答案。
    【解决方案2】:

    好的,经过一夜好眠和更多的stackoverflow/google搜索,我发现了问题:我应该打电话

    imageView.setAdjustViewBounds(true);  
    

    我提交了修复程序,布局看起来不错。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-25
      • 1970-01-01
      相关资源
      最近更新 更多