【发布时间】:2019-07-25 23:45:15
【问题描述】:
我正在从 firebase 将图像加载到 recyclerview item(imageview) 中。 所有图片的尺寸都不同。
我希望我的图像视图根据我正在加载的图像缩放其高度。
主布局.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.RecyclerView
android:id="@+id/RecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>
row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>
<ImageView
android:id="@+id/ImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
在java中我正在做。
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(mctx));
当我滚动 recyclerview 时,它会改变图像高度
然后我上下滚动,查看高度。 Scrolled up/down output
第三次, again scrolled and worst output
请帮帮我..非常感谢..
【问题讨论】:
-
您是否每次都在正确的位置看到正确的图像,即使您快速上下滚动?不仅仅是图片大小
-
@DominikWuttke 是的,我看到了......只有滚动时它们的大小会发生变化......我只希望图像视图根据我加载的图像缩放其高度。谢谢
标签: java android xml android-recyclerview