ANDROID_MARS学习笔记_S01_006ImageView
一、ImageView介绍
设置scalType
Must be one of the following constant values.
| Constant | Value | Description |
|---|---|---|
matrix |
0 | Scale using the image matrix when drawing. See setImageMatrix(Matrix). |
fitXY |
1 | Scale the image using FILL. |
fitStart |
2 | Scale the image using START. |
fitCenter |
3 | Scale the image using CENTER. |
fitEnd |
4 | Scale the image using END. |
center |
5 | Center the image in the view, but perform no scaling. |
centerCrop |
6 | Scale the image uniformly (maintain the image's aspect ratio) so both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). The image is then centered in the view. |
centerInside |
7 | Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). The image is then centered in the view. |
This corresponds to the global attribute resource symbol scaleType.
二、
1.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <ImageView
android:id="@+id/imageViewId"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/images"
android:scaleType="fitXY"
android:background="#00FF00"/> <ImageView
android:id="@+id/imageView2Id"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/wo"
android:background="#FF0000"
android:scaleType="fitXY"/> </LinearLayout>
2.MainActivity.java
private ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.imageview_layout);
iv = (ImageView) findViewById(R.id.imageViewId);
iv.setImageResource(R.drawable.images);
iv.setScaleType(ScaleType.CENTER_INSIDE);
ANDROID_MARS学习笔记_S01_006ImageView的更多相关文章
- ANDROID_MARS学习笔记_S01_012_RatingBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_012_SeekBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_011ProgressBar
文档是这样来设置样式 <ProgressBar android:layout_width="wrap_content" android:layout_height=" ...
- ANDROID_MARS学习笔记_S01_010日期时间控件
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_009Relative_LAYOUT例子
1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...
- ANDROID_MARS学习笔记_S01_008Linear_layout例子
1.netstone_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- ANDROID_MARS学习笔记_S01_007Linear_layout嵌套与layout_weight的设置
一.介绍 二.1.linear_layout.xml <?xml version="1.0" encoding="utf-8"?> <Line ...
- ANDROID_MARS学习笔记_S01_005CheckBox
一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...
- ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算
一.dpi.dp介绍 sp会随着用户在手机中设置字体大小而改变,而dp不会 二.1.dpsp_layout.xml <?xml version="1.0" encoding= ...
随机推荐
- spring定时器 @component
1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到spr ...
- NOIP201101&&05
NOIP200701奖学金 难度级别:A: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 某小学最近得到了一笔赞助 ...
- TIMAC 学习笔记(三)
本文主要内容参考 <Security on TI IEEE 802.15.4 Compliant RF Devices>.<Design Note DN108>.<IEE ...
- centos7搭建NIS与NFS综合应用
实验环境: centos7(服务端) redhat enterprise linux 7.2(客户端) 实验目的:用centos7的账号,能在redhat enterprise linu ...
- 《APUE》第6章练习1
问题:编写一个程序,它调用uname并输出utsname结构中的所有字段,并将输出与uname(1)命令的输出结构做比较. 我本来以为utsname结构也跟passwd结构一样,也有那三个函数来获取整 ...
- [译]Java Thread join示例与详解
Java Thread join示例与详解 Java Thread join方法用来暂停当前线程直到join操作上的线程结束.java中有三个重载的join方法: public final void ...
- json 语义分析
json 中:元素与值用冒号 ":" 隔开元素与元素用逗号 "," 隔开{} 之间是一个对象, 对象可以层层嵌套[] 表示数组, 数组元素用逗号 ", ...
- C语言的32个关键字
由ANSI标准定义的C语言关键字共个: auto double int struct break else long switch case enum register typedef char ex ...
- PAT乙级真题1002. 写出这个数 (20)(解题)
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值.这里保证n小于10100. 输出格式:在一行内输出n的各位数字之和的每 ...
- Oracle “CONNECT BY” 使用
Oracle “CONNECT BY” 使用 功能说明: 语法结构如下: [ START WITH condition ] CONNECT BY [ NOCYCLE ] condition 说明: 1 ...