Android ImageView ScaleTypes介绍
原文地址:http://bon-app-etit.blogspot.hk/2014/01/p_w_picpathview-scaletypes.html
当图片要在应用程序上显示的时候,我们需要关心它将以怎样的方式进行缩放,最基本的方式是在布局文件中的ImageView中设置正确的缩放类型(scaleType)。
Android中ImageView提供了以下不同的缩放类型:
center
centerInside
centerCrop
fitXY
fitStart
fitCenter(默认)
fitEnd
matrix(用于图片的矩阵转换)
下面提供设置不同的缩放类型ImageView显示的截图
布局文件:
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:src="@drawable/logo"android:scaleType="centerCrop"/></RelativeLayout>
图片大于给定的空间截图:
图片小于给定的空间截图:
PS:通过对比每种ScaleType的缩放效果图,加深对ScaleType的理解。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。