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= ...
随机推荐
- c# winform 点菜宝接口demo程序
前几天写了一篇关于c#调用 win32API的文章,有同学对点菜宝接口感兴趣,所以就把写的demo程序共享出来,大家一起讨论改进,so放百度云地址: 百度云下载地址
- Android版的疯狂猜图游戏源码完整版分享
这个游戏源码是在安装教程网那么分享过来的,Android版的疯狂猜图游戏源码完整版分享,也是本人之前很早以前发的一款游戏源码的,大家如果想了解一下,可以看看吧,不说多了,上一个图先吧. > ...
- Spark Streaming揭秘 Day7 再探Job Scheduler
Spark Streaming揭秘 Day7 再探Job Scheduler 今天,我们对Job Scheduler再进一步深入一下,对一些更加细节的源码进行分析. Job Scheduler启动 在 ...
- 《WPF程序设计指南》读书笔记——第7章 Canvas
1.Canvas面板 using System; using System.Windows; using System.Windows.Controls; using System.Windows.M ...
- 【趟坑】公共引用的jar包 pom的配置方法
http://www.cnblogs.com/viewcozy/p/4789877.html 接上一篇 ,内部moudule生成jar的方式 上一篇已经实现了,想把jar作为公共的部分让任何项目都可以 ...
- 进程、线程、GDI+、XML、委托
进制 表示某一位置上的数运算时是逢X进一位.二进制就是逢二进一, 十进制是逢十进一,十六进制是逢十六进一,以此类推. so:二进制001010101只有0和1计算机中的数据都是二进制表示,四进制以0. ...
- c#3位一分(money)
NumberFormatInfo num = new NumberFormatInfo(); num.NumberDecimalDigits = 2; string ...
- C# Windows - TabControl
TabControl控件的属性 - 一般用于控制TabPages对象容器的外观,特别是显示的选项卡的外观 属性 说明 Alignment 控制选项卡在选项卡控件的什么位置显示 Appearance 控 ...
- C# - 高级方法参数
可选参数 -必须有个默认值,默认值必须是字面值,常量值,新对象实例或者默认值类型值. public List<string> GetWords( string sentence, bool ...
- DB天气app冲刺二阶段第一天
原来找人也是个力气活...好费劲呀..今天的进度有点慢,,确切的说是没有什么进度 因为不会弄了..加上今天一个劲的找同学帮忙写评论.心思没定下来 根本没思路了..明天按照今天的计划继续冲刺..