2015年2月21日 星期六

[Android] ImageView adjustViewBounds 圖 自動調整大小


如果imageview設定
android:layout_width="fill_parent"
android:layout_height="wrap_content"
當圖的寬大於imageview的寬,會自動縮成如下,其中還有ScaleType的多種選項可用,但之前一直遇到的問題是,不論怎麼設定ScaleType,下方黃色空間還是會被imageview佔住,想放textview還是button都會被遮住,
If I set imageview like these,
android:layout_width="fill_parent"
android:layout_height="wrap_content"
When the width of picture is larger than the imageview, the picture will be auto scaled to fit the imageview. There are many ScaleType option that can be set. The problem is, no matter how I set the ScaleType, the yellow area is occupied by the imageview

後來找了一陣子發現只要加上這行
android:adjustViewBounds="true"
imageview就會自動縮成picture的大小,還你黃色的空間。

After studying from internet, I got this
android:adjustViewBounds="true"
The imageview will auto scale to the size of picture, and then you can use the yellow area.



沒有留言:

張貼留言