I have a Recyclerview displaying a grid of pictures from the external storage. On all the devices that I have tested including a Xiami,Nexus7, Samsung S3, one +2, Moto G-2 etc, the recyclerview correctly displays the picture. I am using the Glide image loading lib to load pics.
I have set the adapter using the folowing
savedPhotosGridLayoutManager = new GridLayoutManager(application, SPAN_COUNT);
savedPhotosGrid.setLayoutManager(savedPhotosGridLayoutManager);
savedPhotosGrid.addItemDecoration(new ItemOffsetDecoration(application, R.dimen.grid_save_spacing));
savedPhotosGrid.setAdapter(savedPhotosGridAdapter);
savedPhotosGrid.setHasFixedSize(true);
An item in a row has the following xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/item_recycler_view">
<ImageView
android:id="@+id/savedPhoto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:transitionName="imageScale" />
<ImageView
android:id="@+id/mask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/savedPhoto"
android:layout_alignEnd="@+id/savedPhoto"
android:layout_alignLeft="@+id/savedPhoto"
android:layout_alignRight="@+id/savedPhoto"
android:layout_alignStart="@+id/savedPhoto"
android:layout_alignTop="@+id/savedPhoto"
android:background="@drawable/item_recycler_view"
android:clickable="true" />
</RelativeLayout>
I load images into this using Glide.
Glide.with(context).load(savedImageFilePaths.get(i)).override(100, 100).centerCrop().into(viewHolder.savedImage);
For some strange reason, on a Samsung S4, the recyclerview item does not display correctly. The rows look cropped, what should be a square(since I am loading a 100 by 100 image), is a cropped version of it. The width is correct while the height of the row is incorrect(shorter than it should be).
Only if I hardcode the values in xml to be 100 dp by 100 dp , does it show correctly on the S4. This is clearly strange since all the other devices I tested the app on clearly display the square image in the grid(recyclerview) correctly.
Is this a bug or am I going wrong some where/missing something?