android中ImageView属性scaletype的设置
2014-08-03 12:22
381 查看
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"/>
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"/>
相关文章推荐
- ImageView的属性android:scaleType设置最佳比例图片显示
- ImageView的属性android:scaleType设置最佳比例图片显示
- ImageView的属性android:scaleType设置最佳比例图片显示
- ImageView的属性android:scaleType,即ImageView.setScaleType(ImageView.ScaleType)
- Android_ImageView.ScaleType属性图文详解
- [Android] ImageView.ScaleType设置图解
- [Android] ImageView.ScaleType设置图解
- [Android] ImageView.ScaleType设置图解
- [Android] ImageView.ScaleType设置图解
- android ImageView scaleType属性
- ImageView的属性android:scaleType,即ImageView.setScaleType(ImageView.ScaleType)
- [Android] ImageView.ScaleType设置图解
- android ImageView scaleType属性
- [Android] ImageView.ScaleType设置图解
- android ImageView scaleType属性
- android ImageView android:scaleType属性详解
- 【ImageView】图片自适应及android:scaleType属性
- [Android] ImageView.ScaleType设置图解
- [Android] ImageView.ScaleType设置图解
- ImageView的属性android:scaleType,即ImageView.setScaleType(ImageView.ScaleType)