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. BBS论坛 项目表分析

    一.项目表分析 from django.db import models from django.contrib.auth.models import AbstractUser # Create yo ...

  2. 转: https原理:证书传递、验证和数据加密、解密过程解析

    原本连接:http://www.cnblogs.com/zhuqil/archive/2012/07/23/2604572.html 我们都知道HTTPS能够加密信息,以免敏感信息被第三方获取.所以很 ...

  3. css---5 only-child or nth-of-type

    1  _nth-child系列 :nth-child(index) <!DOCTYPE html> <html lang="en"> <head> ...

  4. Python自学:第五章 使用函数range( )

    # -*- coding: GBK -*- for value in range(1,5): print(value) 输出为: 1 2 3 4

  5. leetcood学习笔记-82-删除排序链表中的重复元素二

    题目描述: 方法一: class Solution(object): def deleteDuplicates(self, head): """ :type head: ...

  6. 【JZOJ6342】Tiny Counting

    description analysis 首先不管\(a,b,c,d\)重复的情况方案数是正逆序对之积 如果考虑\(a,b,c,d\)有重复,只有四种情况,下面括号括起来表示该位置重复 比如\(\{a ...

  7. JS预解析与变量提升

    预解析 JavaScript代码的执行是由浏览器中的JavaScript解析器来执行的.JavaScript解析器执行JavaScript代码的时候,分为两个过程:预解析过程和代码执行过程 预解析过程 ...

  8. (JS)应为","

    在写cshtml的时候,vs提示:(JS)应为"," 功能无法实现,一般是因为 标点切成全角了,但是我是应为把‘’打成了“” 以下错误示范: $("ol").a ...

  9. 关于Async与Await的FAQ

    =============C#.Net 篇目录============== 环境:VS2012(尽管System.Threading.Tasks在.net4.0就引入,在.net4.5中为其增加了更丰 ...

  10. cookie的设置与销毁

    <?php /* 2个参数设置cookie cookie随着浏览器的关闭,就失效了 ); /* 下面我们让cookir多活一会 3个参数来设置cookie,第3个参数指的就是cookie的声明周 ...