android中ImageView属性scaletype的设置

1.android:adjustViewBounds :与android:maxWidth 和 android:maxHeight一起使用.


2.android:scaleType总共有8个 值:(在代码中调用imageView.setScaleType(ImageView.ScaleType.CENTER);)

1.fitXY-----> 不按比例缩放图片,目标是把图片塞满整个View.(Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="fitXY"
        android:src="@drawable/a1"/>

    


2.fitStart----->把图片按比例扩大/缩小到View的宽度,顶部显示START aligns the result to the left and top edges of dst.

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="fitStart"
        android:src="@drawable/a1"/>



3.fitCenter---->把图片按比例扩大/缩小到View的宽度,居中显示 Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. The result is centered inside dst.

 <ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="fitCenter"
        android:src="@drawable/a1"/>




4.fitEnd---> 把图片按比例扩大/缩小到View的宽度,底部显示 Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. END aligns the result to the right and bottom edges of dst.

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="fitEnd"
        android:src="@drawable/a1"/>



5.center----->按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示Center the image in the view, but perform no scaling. 

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="center"
        android:src="@drawable/a1"/>




6.centerCrop-----> 按比例扩大图片的size居中显示,使得图片长(宽)等于或大于View的长(宽) Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). 

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="centerCrop"
        android:src="@drawable/a1"/>





7.centerInside---->将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽 Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). 

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="centerInside"
        android:src="@drawable/a1"/





8.matrix---->用矩阵来绘图

<ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scaleType="matrix"
        android:src="@drawable/a1"/>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值