2016-02-17 86 views
3

工作我在执行adjustViewBounds=true工程完全按照预期的是Android 5.1 但不会做相同的4.1的Android ImageView的,adjustViewBounds不是安卓4.1

4.1在左边,5.1右边

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> 
+0

参考http://stackoverflow.com/问题/ 7719617/imageview的-adjustviewbounds - 不工作 – sasikumar

回答

0

如果应用程序的目标API级17或更低adjustViewBounds无线将允许drawable缩小视图边界,但不会增长以填充所有情况下可用的测量空间。这是为了与传统的MeasureSpec和RelativeLayout行为兼容。

等API级别17,少你必须使用一个AdjustableImageView

在gradle这个

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

下面添加详细教程See this