在我的实现中,adjustViewBounds=true
在 android 5.1 中完全符合预期
但在 4.1 中不做同样的事情
4.1 on left, 5.1 on right
adjustViewBounds=true
adjustViewBounds=false
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>
最佳答案
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.
所以在 Api 级别 17 及以下你必须使用 AdjustableImageView
在gradle下面添加
compile 'com.inthecheesefactory.thecheeselibrary:adjustable-imageview:1.0.0'
详细教程See this
关于Android ImageView,adjustViewBounds 在 Android 4.1 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35450319/