1、相关属性

        <!--src 设置内容-->
<!--background 设置背景-->
<!--alpha 设置透明度 -->
<!--adjustViewBounds 保持原图宽高比-->
<!--maxHeight maxWidth最大宽度和高度:adjustViewBounds为true,布局宽高为wrap_content才能生效-->
<!--scaleType 缩放类型-->

  scaleType属性详解:

fitXY:对图像的横向与纵向进行独立缩放,使得该图片完全适应ImageView;
fitStart:保持纵横比缩放图片,直到较长的边与ImageView的编程相等,缩放完成后将图片放在ImageView的左上角;
fitCenter:保持纵横比缩放图片,直到较长的边与ImageView的编程相等,缩放后放于中间;
fitEnd:保持纵横比缩放图片,直到较长的边与ImageView的编程相等,缩放后放于右下角;
center:保持原图的大小,显示在ImageView的中心。超过部分裁剪处理;
centerCrop:保持横纵比缩放图片,完全覆盖ImageView;
centerInside:保持横纵比缩放图片,直到ImageView能够完全地显示图片;
matrix:默认值,不改变原图的大小,从ImageView的左上角开始绘制原图,超过部分作裁剪处理;

2、简单使用

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LoginActivity"> <!--src 设置内容-->
<!--background 设置背景-->
<!--alpha 设置透明度 -->
<!--adjustViewBounds 保持原图宽高比-->
<!--maxHeight maxWidth最大宽度和高度:adjustViewBounds为true,布局宽高为wrap_content才能生效-->
<!--scaleType 缩放类型-->
<ImageView
android:id="@+id/imageview11"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:src="@drawable/back"
android:background="@color/colorPrimary"/> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageview22"
android:src="@drawable/back"
android:padding="5dp"
android:background="@color/bbutton_danger"
android:alpha="1"
android:adjustViewBounds="true"
android:maxHeight="150dp"
android:maxWidth="150dp"
android:scaleType="fitCenter"
/>
</LinearLayout>

效果图

Android基础控件ImageView的使用的更多相关文章

  1. Android基础控件ListView基础操作

    1.简介 基于Android基础控件ListView和自定义BaseAdapter适配器情况下,对ListView的数据删除和添加操作: public boolean add(E e) {//添加数据 ...

  2. 矩阵, 矩阵 , Android基础控件之ImageView

    天下文章大家抄,以下所有内容,有来自copy,有来自查询,亦有自己的总结(目的是总结出自己的东西),所以说原创,不合适,说是转载也不恰当,所以我称之为笔记,可惜没有此分类选项,姑且不要脸一点,选择为原 ...

  3. android 基础控件(EditView、SeekBar等)的属性及使用方法

        android提供了大量的UI控件,本文将介绍TextView.ImageView.Button.EditView.ProgressBar.SeekBar.ScrollView.WebView ...

  4. Android基础控件ProgressBar进度条的使用

    1.简介 ProgressBar继承与View类,直接子类有AbsSeekBar和ContentLoadingProgressBar, 其中AbsSeekBar的子类有SeekBar和RatingBa ...

  5. Android基础控件Button的使用

    1.相关属性 Android的按钮有Button和ImageButton(图像按钮),Button extends TextView, ImageButton extends ImageView! a ...

  6. android基础控件的使用

    控件在屏幕上位置的确定 通常情况下控件在屏幕上确定至少要连接两条线(一条水平,一条垂直) 如下图连接了四条线 辅助线 辅助线的调出: 水平辅助线:进入activity.xml的设计模式之后如下图 为了 ...

  7. android 基础控件 EditText

    EditText 简介: EditText 控件继承 TextView ,它有TextView的所有属性和方法,并且自身是可编辑的: extends TextView java.lang.Object ...

  8. Android 基础控件 TextView

    一TextView介绍: TextView是UI最基本的组件,使用TextView可以显示丰富的文本信息.设置添加TextView最常见的方法就是在xml中添加TextView元素,并指定属性.Tex ...

  9. Android基础控件TextClock和Chronometer的使用

    1.简介 DigitalClock, TextClock,AnalogClock,Chronometer其中DigitalClock和AnalogClock废弃了! TextClock是在Androi ...

随机推荐

  1. js实现图片资源、blob、base64的各种场景转换

    文件转babase64 function getImgToBase64(url,callback){//将图片转换为Base64 var canvas = document.createElement ...

  2. shell 脚本 变量使用,取消一个变量,echo

    1. 用户自定义变量,直接使用,赋值的时候等号两边不能有空格 A=100 echo "\$A = $A" # $是取变量A 中的值 "" 号中 \$ 是转译,此 ...

  3. TFS 忽略 文件

    原文链接:http://ju.outofmemory.cn/entry/258689 让TFS忽略packages文件夹的更改 很多时候我们需要使用 Nuget 进行包管理,这时在我们的解决方案文件夹 ...

  4. 【笔记篇】(理论向)快速傅里叶变换(FFT)学习笔记w

    现在真是一碰电脑就很颓废啊... 于是早晨把电脑锁上然后在旁边啃了一节课多的算导, 把FFT的基本原理整明白了.. 但是我并不觉得自己能讲明白... Fast Fourier Transformati ...

  5. mui--使用mui中的图文表格组件时出现一条横线的解决方法

    最近做的微信公众号点击链接跳转到H5页面,该H5页面使用mui做的,遇到的商品列表页出现一个横线的问题, 这个是修改前的图片 解决方法: <style type="text/css&q ...

  6. leetcode-212-单词搜索②

    题目描述: 第一次提交:(超出时间限制) class Solution: def findWords(self, board: List[List[str]], words: List[str]) - ...

  7. vsftp 被动模式配置

    直接复制粘切过来就能用 这里只讲下配置,安装方法可以直接yum 配置文件修改 anonymous_enable=NO #关闭匿名用户 xferlog_file=/var/log/vsftpd.log ...

  8. 【JZOJ3424】粉刷匠

    description 赫克托是一个魁梧的粉刷匠,而且非常喜欢思考= = 现在,神庙里有N根排列成一直线的石柱,从1到N标号,长老要求用油漆将这些石柱重新粉刷一遍.赫克托有K桶颜色各不相同的油漆,第i ...

  9. CUDA 关于 BLOCK数目与Thread数目设置

    GPU的计算核心是以一定数量的Streaming Processor(SP)组成的处理器阵列,NV称之为Texture Processing Clusters(TPC),每个TPC中又包含一定数量的S ...

  10. Android Scroller简单用法 --View滚动

    转:http://ipjmc.iteye.com/blog/1615828 Android里Scroller类是为了实现View平滑滚动的一个Helper类.通常在自定义的View时使用,在View中 ...