摘自:安卓APP_ 控件(4)—— ImageView
作者:丶PURSUING
发布时间: 2021-03-29 21:52:06
网址:https://blog.csdn.net/weixin_44742824/article/details/115311375
开篇:安卓APP_ 控件(1)—— TestView
ImageView主要是进行图片的缩放控制:

导入图片时,可能要更改图片名才能使用:
 
 .xml中具体实现代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><!--    图片原来就很大,会默认进行等比例缩放scaleType:     fitCenter  为缩放后放于中间(默认)fitEnd     缩放后放在右下角fitStart   缩放后放在左上角center     保持图片原图大小,超过ImageView范围部分被裁剪centerCrop 保持宽高等比缩放,直到完全覆盖ImageViewmatrix     从图片的左上角开始绘制,能画多少是多少。如果图片大,就只能看到左上角src:  引用图片资源-->    <ImageViewandroid:layout_width="270dp"android:layout_height="423dp"android:scaleType="fitCenter"android:src="@drawable/test1" /><!--    maxWidth/maxHeight/adjustViewBounds的重要用法使得控件ImageView的大小和图片的大小一样,并且为等比例缩放adjustViewBounds 调整view的界限       maxWidth  最大宽度--><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:adjustViewBounds="true"android:maxWidth="300dp"android:maxHeight="300dp"android:src="@drawable/test2" /></LinearLayout>