android:scaleType="matrix"布局文件载入图片时候的显示方式

android:scaleType="center" 

以原图的几何中心点和ImagView的几何中心点为基准,按图片的原来size居中显示,不缩放,当图片长/宽超过View的长/宽。则截取图片的居中部分显示ImageView的size.当图片小于View 的长宽时。仅仅显示图片的size,不剪裁。

android:scaleType="centerCrop"

 以原图的几何中心点和ImagView的几何中心点为基准,按比例扩大(图片小于View的宽时)图片的size居中显示,使得图片长 (宽)等于或大于View的长(宽),并按View的大小截取图片。当原图的size大于ImageView时。按比例缩小图片。使得长宽中有一向等于ImageView,还有一向大于ImageView。实际上,使得原图的size大于等于ImageView的长(宽)。


android:scaleType="centerInside"

 以原图的几何中心点和ImagView的几何中心点为基准。将图片的内容完整居中显示。通过按比例缩小原来的size使得图片长(宽)等于或小于ImageView的长(宽)。


android:scaleType="fitCenter" 把图片按比例扩大(缩小)到View的宽度,居中显示

android:scaleType="fitEnd" 把图片按比例扩大(缩小)到View的宽度,显示在View的下部分位置

android:scaleType="fitStart" 把图片按比例扩大(缩小)到View的宽度。显示在View的上部分位置

android:scaleType="fitXY" 把图片依照指定的大小在View中显示,拉伸显示图片。不保持原比例,填满View.


android:scaleType="matrix" 用matrix来绘制(默认)。

<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; tools:context=&quot;.Fragment_1&quot;> <LinearLayout android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:orientation=&quot;vertical&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot;> <TextView android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:background=&quot;@color/colorAccent&quot; android:gravity=&quot;center&quot; android:text=&quot;wall美图&quot; android:textColor=&quot;@color/black&quot; android:textSize=&quot;30dp&quot; /> <ViewFlipper android:id=&quot;@+id/banner&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:layout_weight=&quot;1&quot; android:inAnimation=&quot;@anim/left_in&quot; android:outAnimation=&quot;@anim/right_out&quot;> <ImageView android:id=&quot;@+id/banner_1&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;213dp&quot; android:scaleType=&quot;fitXY&quot; app:srcCompat=&quot;@mipmap/lbt_1&quot; /> <ImageView android:id=&quot;@+id/banner_2&quot; android:scaleType=&quot;fitXY&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; app:srcCompat=&quot;@mipmap/lbt_2&quot; /> <ImageView android:id=&quot;@+id/banner_3&quot; android:scaleType=&quot;fitXY&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; app:srcCompat=&quot;@mipmap/lbt_3&quot; /> <ImageView android:id=&quot;@+id/banner_4&quot; android:scaleType=&quot;fitXY&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; app:srcCompat=&quot;@mipmap/lbt_4&quot; /> <ImageView android:id=&quot;@+id/banner_5&quot; android:scaleType=&quot;fitXY&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; app:srcCompat=&quot;@mipmap/lbt_5&quot; /> </ViewFlipper> <View android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;1dp&quot; android:background=&quot;@color/black&quot;/> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>轮播图不会自动轮播
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值