3

In my implementation adjustViewBounds=true works exactly as expected in android 5.1 but doesn't do the same in 4.1

4.1 on left, 5.1 on right

adjustViewBounds=true

enter image description here

adjustViewBounds=false

enter image description here

MainFragment

<GridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="150dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="0dp"
    android:horizontalSpacing="0dp"
    android:stretchMode="columnWidth"
    tools:context=".MainFragment"
    android:id="@+id/movie_gridView">
</GridView>

ImageView

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:id="@+id/gridView_moviePoster"
        android:adjustViewBounds="true"/>
</FrameLayout>
Rohit Karadkar
  • 832
  • 10
  • 18

1 Answers1

0

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 is for compatibility with legacy MeasureSpec and RelativeLayout behavior.

so On Api level 17 and less you have to use an AdjustableImageView

Add below in gradle

compile 'com.inthecheesefactory.thecheeselibrary:adjustable-imageview:1.0.0'

For detail tutorial See this

Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300