ImageView
主要属性
- android:src 设置图片资源
- android:scaleType 设置图片缩放类型
- android:maxHeight 最大高度
- android:maxWidth 最大宽度
- android:adjustViewBounds 调整View的权限
缩小类型
- fitStart 保持宽高比缩放图片,直到较长的边与Image的边长相等,缩放完成后将图片放在ImageView的左上角
- fitCenter 默认值,同上,缩放后放于中间
- fitEnd 同上,缩放后放于右下角
- fitXY 对图像的横纵方向进行独立缩放,使得该图片完全适应ImageView,但是图片的宽高比可能会发生改变
- center 保持原图的大小,显示在ImageView的中心。当原图的size大于ImageView的size,超过部分裁剪处理。
- centerCrop 保持宽高比缩放图片,直到完全覆盖ImageView,可能会出现图片的显示不完全
- centerlnside 保持宽高比缩放图片,直到ImageView能够完全地显示图片
- matrix 不改变原图地大小,从ImageView的左上角开始绘制原图,原图超过ImageView的部分做裁剪处理
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:src="@drawable/thankyou"
android:scaleType="fitStart"
android:layout_width="200dp"
android:layout_height="200dp" />
<ImageView
android:src="@drawable/thank"
android:maxHeight="200dp"
android:maxWidth="200dp"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
![MyImageView](https://i-blog.csdnimg.cn/blog_migrate/0887eb06418a6271d5a77ff353188f2f.jpeg)