I use this layout to show an image in my RecyclerView
:
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
I load a picture with Glide library like that:
Glide.with(context)
.load(my_url)
.skipMemoryCache(true)
.placeholder(R.drawable.default_medium_wide_picture)
.crossFade()
.into(contentHolder.mImageView);
The height of ImageView
is computed during the viewholder creation according the width screen:
DisplayMetrics metrics = MyApplication.getInstance().getResources().getDisplayMetrics();
imageView.getLayoutParams().height = Math.round(metrics.widthPixels * Defines.IMAGE_HEIGHT_RATIO);
The result is perfect on 4.4.4 Android version:
But on 4.1.1 Android version the result expected is bad:
Thanks by advance guys for your help!
You just can use
centerCrop
of Glide and remove the calculation of height based on width.