温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android ImageView ScaleTypes介绍

发布时间:2020-07-02 17:50:00 来源:网络 阅读:1004 作者:secondriver 栏目:移动开发

  

       原文地址:http://bon-app-etit.blogspot.hk/2014/01/p_w_picpathview-scaletypes.html

    

       当图片要在应用程序上显示的时候,我们需要关心它将以怎样的方式进行缩放,最基本的方式是在布局文件中的ImageView中设置正确的缩放类型(scaleType)。


       Android中ImageView提供了以下不同的缩放类型:

     

  • center

  • centerInside

  • centerCrop

  • fitXY

  • fitStart

  • fitCenter(默认)

  • fitEnd

  • matrix(用于图片的矩阵转换)


   下面提供设置不同的缩放类型ImageView显示的截图

     

    布局文件:

     

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/logo"
        android:scaleType="centerCrop" />

</RelativeLayout>

    


     图片大于给定的空间截图:


     Android ImageView ScaleTypes介绍



     图片小于给定的空间截图:

     Android ImageView ScaleTypes介绍

   

   PS:通过对比每种ScaleType的缩放效果图,加深对ScaleType的理解。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI