我在使用 StaggeredGridLayoutManager
显示 RecyclerView
时遇到问题,其项目包含 imageview
并且图像加载到 imageview
使用 glide
。
我面临的问题是,在加载图像后,它们不会交错并且大小相等,两列之间也有很大的差距。如何改变图像的高度而不在列中留有间隙?
最佳答案
我遇到了同样的问题。对我有用的是为我的 ImageView 设置 android:adjustViewBounds="true"
。我什至没有设置 scaleType。
这是我的布局文件 item.xml 的全部内容。
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gif_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorFiller"
android:adjustViewBounds="true"/>
希望这对您有所帮助!
关于android - 带有 StaggeredGridLayoutManager 的 RecyclerView,图像从 Glide 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36149213/