adjustViewBounds屬性的定義如下:
調整ImageView的邊界,使得ImageView和圖片有一樣的寬高比
這個屬性只有在ImageView一邊如寬度或高度固定,一邊為wrap_content的時候才有意義,設置為true的時候,可以讓ImageView的比例和原始圖片一樣,以達到讓圖片充滿ImageView的效果。
<ImageView android:id="@+id/iv_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:background="@android:color/red" android:src="@drawable/cheese_1" />