I'm trying to use the StaggeredGridLayoutManager with CardView from android.support.v7.widget
(v22).
This is my item's layout:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="6dp" >
<RelativeLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dip" >
<ImageView
android:id="@+id/photo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
On emulators and on devices 5.0+ it is ok and works well, but on emulators 4.x.x the image is not resized to fill the item's width / height (as there was like a scale type centerInside that not fit the item's measure ). I cant now try it on real 4.x.x devices, does anyone know if it is a problem only in the emulator or even in some real 4.x.x devices?
SOLVED from docs http://developer.android.com/reference/android/widget/ImageView.html#setAdjustViewBounds(boolean)]1
If the application targets API level 17 or lower, adjustViewBounds will allow the drawable to shrink the view bounds, but not grow to fill available measured space in all cases.
This issue is related only to the behavior of android:adjustViewBounds="true"
, which seems that from Android 4.3 to be able to scale the image in ImageView not only to resize the native dimensions downward but also upward keeping the ratio.