給產品更多發揮餘地的圖片控件寫法

剖析這個需求,需要做到的要求:

1、給定最大高度、最大寬度;

2、在這個最大區域內,把圖片的一維縮放到最大值,保證圖片完整顯示在區域內。

轉化要求爲實現:ImageView

1、wrap_content寬高;
android:layout_width="wrap_content"
android:layout_height="wrap_content"

2、設置最大寬高,adjustViewBounds設置纔有效;
android:maxHeight="@dimen/p44"
android:maxWidth="@dimen/p105"
android:adjustViewBounds="true"
3、習慣性保障完整顯示在區域內。
android:scaleType="fitCenter"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章