图片adjustviewbound属性 和Scaletype

来源:互联网 发布:python for迭代 next 编辑:程序博客网 时间:2024/06/05 00:47

adjustviewbound属性=true  可以使得图片保持宽高比

adjustViewBounds: 是否去调整这个视图的界限去保存绘制的初始范围比例;



应用  图片scaletype =fixXy 后设置 adjustviewbound属性=true     可以保持图片宽高比的效果 并且又不会出现 scaletype =fit  center 的裁剪掉图片边缘的效果


     Tablayout中  set custom view 中设置自定义view    配合match_parent , 可以使得图片能获得最大的视图, 并且宽高比不变化. 

           在这个情况下 如果使用dp固定值过大  即便在大手机有良好表现但会使得在小手机上图片被截取,.  

如果不写adjustviewbound属性=true    图片会因为需要保持宽高比不裁剪图片而缩小图片.


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              android:orientation="vertical"              android:id="@+id/ll_item"              android:background="@drawable/tab_bg_selector"              android:layout_width="match_parent"              android:layout_height="match_parent">    <ImageView        android:adjustViewBounds="true"        android:background="@drawable/tab_iv_selector"        android:id="@+id/icon_item"        android:layout_gravity="center"        android:layout_width="match_parent"        android:layout_height="match_parent"        /></LinearLayout>

0 0