Android基础控件ImageView的使用
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的使用的更多相关文章
- Android基础控件ListView基础操作
1.简介 基于Android基础控件ListView和自定义BaseAdapter适配器情况下,对ListView的数据删除和添加操作: public boolean add(E e) {//添加数据 ...
- 矩阵, 矩阵 , Android基础控件之ImageView
天下文章大家抄,以下所有内容,有来自copy,有来自查询,亦有自己的总结(目的是总结出自己的东西),所以说原创,不合适,说是转载也不恰当,所以我称之为笔记,可惜没有此分类选项,姑且不要脸一点,选择为原 ...
- android 基础控件(EditView、SeekBar等)的属性及使用方法
android提供了大量的UI控件,本文将介绍TextView.ImageView.Button.EditView.ProgressBar.SeekBar.ScrollView.WebView ...
- Android基础控件ProgressBar进度条的使用
1.简介 ProgressBar继承与View类,直接子类有AbsSeekBar和ContentLoadingProgressBar, 其中AbsSeekBar的子类有SeekBar和RatingBa ...
- Android基础控件Button的使用
1.相关属性 Android的按钮有Button和ImageButton(图像按钮),Button extends TextView, ImageButton extends ImageView! a ...
- android基础控件的使用
控件在屏幕上位置的确定 通常情况下控件在屏幕上确定至少要连接两条线(一条水平,一条垂直) 如下图连接了四条线 辅助线 辅助线的调出: 水平辅助线:进入activity.xml的设计模式之后如下图 为了 ...
- android 基础控件 EditText
EditText 简介: EditText 控件继承 TextView ,它有TextView的所有属性和方法,并且自身是可编辑的: extends TextView java.lang.Object ...
- Android 基础控件 TextView
一TextView介绍: TextView是UI最基本的组件,使用TextView可以显示丰富的文本信息.设置添加TextView最常见的方法就是在xml中添加TextView元素,并指定属性.Tex ...
- Android基础控件TextClock和Chronometer的使用
1.简介 DigitalClock, TextClock,AnalogClock,Chronometer其中DigitalClock和AnalogClock废弃了! TextClock是在Androi ...
随机推荐
- Vue的项目搭建及请求生命周期
目录 Vue的项目搭建及请求生命周期 Vue-CLI的项目搭建 环境搭建 项目创建 pycharm运行Vue项目 Vue项目的大体结构 Vue的请求生命周期 两个小用法 Vue的项目搭建及请求生命周期 ...
- ASP.NET Core Web应用在发布时选择是否对视图进行编译
原文:ASP.NET Core Web应用在发布时选择是否对视图进行编译 在我们发布ASP.NET Core Web应用程序时,选择以文件形式发布,发布方法选择文件系统 默认情况下,会把Views的视 ...
- D3.js的基础部分之数组的处理 集合(Set)(v3版本)
数组的处理 之 集合(set) 集合(Set)是数学中常用的概念,表示具有某种特定性质的事物的总体.集合里的项叫做元素.集合的相关方法有: d3.set([array]) //使用数组来构建集合, ...
- JDBC_数据库连接池c3p0
/** * @Description: TODO(这里用一句话描述这个类的作用) * @Author aikang * @Date 2019/8/26 20:12 */ /* 1.数据库连接池: 1. ...
- 2019-3-16-win10-uwp-在-ItemsPanelTemplate-里面通过样式绑定-Orientation-显示方向
title author date CreateTime categories win10 uwp 在 ItemsPanelTemplate 里面通过样式绑定 Orientation 显示方向 lin ...
- 9_山寨系统调用 SystemCallEntry
思想: 再次在 GDT 中偷内存 搭建 系统调用需要的 逻辑框架与功能实现: 基本分解妄想: 构建系统调用的代码: 拷贝到 偷取的内存中: idt 向量 序号21位置: 8003ee00`0008f1 ...
- vue(1) 第一个例子
代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...
- C/C++实现单向循环链表(尾指针,带头尾节点)
C语言实现单向循环链表,主要功能为空链表创建,链表初始化(头插法,尾插法),链表元素读取,按位置插入,(有序链表)按值插入,按位置删除,按值删除,清空链表,销毁链表. 单向循环链表和单向链表的区别:( ...
- python用类实现装饰器
一.代码 #利用__call__方法,装饰器的执行流程:当添加装饰器语法糖时,会把语法糖的变量名加()执行,并将被装饰的函数名传入.所以当类加()执行时,执行了__init__,产生的对象就是被装饰的 ...
- H5页面在手机上查看 使用手机浏览自己的web项目
参考:http://www.browsersync.cn/#install 首先全局安装BrowserSync : npm install -g browser-sync 其次在项目文件夹下运行: b ...