[英]Android imageview, scale full screen, and centerCrop
如何使用圖像填充屏幕的圖像視圖,但保持其縱橫比,並適合中心?
目前我有大圖像,大於手機屏幕分辨率,但我懷疑它們將被裝在具有更高分辨率的設備上
scaleType
哪種組合可以scaleType
?
您可以簡單地使用adjustViewBounds
值來維護圖像的縱橫比
<ImageView
android:id="@+id/metallicaImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/metallica" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />
這是一個基本設置。
我之前遇到過這個問題,問題是當圖像需要按比例放大(屏幕寬度大於圖像)時,Android不會將圖像縮放到超出給定大小的范圍。 但是,按比例縮小效果很好。
我最終創建了下面提到的AspectRatioImageView
,效果很好。 請務必閱讀有關getIntrinsicWidth()
返回0和getDrawable()
返回null的注釋,並對其進行一些安全檢查。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.