------ adjustViewBounds属性要求api level 不小于18
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.
------- 代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.gaos.viewanimation.MainActivity">
<ImageView
android:id="@+id/imgview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/superman" />
</RelativeLayout>
----------- 当我不限制ImageView的高度时
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.gaos.viewanimation.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/superman" />
</ScrollView>
</RelativeLayout>