Anfroid 在界面中显示图片 ImageView
ImageView
1.什么是ImageView
是显示图片的一个控件
2.ImageView属性
android:src ImageView的内容颜色
android:background ImageView背景图片
android:color ImageView的RGB颜色
项目里我新建了一个Icon,名为ic_lena。
这个项目用于演示ImageView的src属性和bakground的区别。
src和background属性可以同时存在。
ImageView部分的代码片段:
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_lena"
android:background="#00FFFF"
/>
<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:orientation="vertical"
> <ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_lena"
android:background="#00FFFF"
/> <ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_lena" /> <ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#00FFFF" /> <ImageView
android:id="@+id/imageView3"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/ic_lena" /> </LinearLayout>
fragment_main.xml
不同分辨率下图片的显示:
ic_lena图片:

效果:

Anfroid 在界面中显示图片 ImageView的更多相关文章
- C++ 在界面中添加图片
#include <stdio.h> #include <easyx.h> #include <graphics.h> void huayuan() { Begin ...
- iOS开发小技巧--即时通讯项目:使用富文本在UILabel中显示图片和文字;使用富文本占位显示图片
Label借助富文本显示图片 1.即时通讯项目中语音消息UI的实现,样式如图: 借助富文本在UILabel中显示图片和文字 // 1.创建一个可变的富文本 NSMutableAttributedStr ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包括图像的文本信息).并简要说明实现方法. 答案:Android SDK支持例如以下显示富文本信息的方式. 1.使用T ...
- 图解android开发在界面上显示图片
图解android开发在界面上显示图片<申明:转自百度> <原文章地址:http://jingyan.baidu.com/article/49711c6153a277fa441b7c ...
- [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget (第一部分)
本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包含图像的文本信息),并简要说明实现方法. 答案:Android SDK支持如下显示富文本信息的方式. 1.使用Tex ...
- 在HTML中显示图片时希望如果图片不存在或者无法显示时,能够显示默认图片
很多时候,在HTML中显示图片时希望如果图片不存在或者无法显示时,能够显示默认图片.可以通过以下方式: <img src="xxx.jpg" onError="th ...
- 在博客中显示图片_Mac版
主要是防止自己忘掉 为了解决一开始自己想在写入的博客中添加本地图片,直接链接的话在自己的电脑倒是可以显示图片,但是在别人的电脑上就没办法加载图片了,问各路大神也没人愿意解答,百度也没有想要的答案,只好 ...
- Java中显示图片的方法
最近在做一个swing小项目,其中需要把存储在硬盘中的图片文件显示出来,总结了如下方法: 1. Graphics g = getGraphics();String name = "E:/Ca ...
随机推荐
- 7处ff与ie中读写html、css相关属性的不同之处
1. float样式属性 IE syntax: document.getElementById("test").style.styleFloat = "left" ...
- H - Quicksum(1.5.3)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...
- 广度优先遍历目录(Windows平台、C++)
深度优先的遍历网上一大把,就是递归调用,这里就不说了,说点网上找不到的. #include <Windows.h> #include <stdint.h> #include & ...
- 初看mysql源代码之mysql.cc
在mysql的源代码目录中,sql目录是mysql源代码中经常变化的目录之一,也是MySQL服务器内核最为核心和重要的目录. sql目录除了包含mysqld.cc这一MySQL main函数所在文件外 ...
- Yii 中Criteria常用方法
$criteria = new CDbCriteria; //select $criteria->select = '*';//默认* $criteria->select = 'id,na ...
- windows和Linux查看端口占用进程并关闭
Windows: 以端口8080为例: 1.查找对应的端口占用的进程:netstat -aon|findstr "8080" ,找到占用8080端口对应的程序的PID号: ...
- MySql C++调用库Connector/c++编译 和 接口封装【一】mysql数据库安装
Connector/c++库的源文件编译,你需要先准备好以下工具: mysql数据库(编译时要依赖),boost库,cmake(生成sln工程文件),connector/c++的源文件,vis ...
- 各种api接口
实用号码归属地查询(IP 地址,手机号码): 默认格式: http://api.liqwei.com/location/ (使用来访者的 IP 地址) 指定 IP 地址格式: http://api.l ...
- HBase二级索引方案总结
转自:http://blog.sina.com.cn/s/blog_4a1f59bf01018apd.html 附hbase如何创建二级索引以及创建二级索引实例:http://www.aboutyun ...
- 关于Cocos2d-x中定时器的使用总结
1.定义 定时器在大部分游戏中是不可或缺的,即每隔一段时间,就要执行相应的刷新体函数,以更新游戏的画面.时间.进度.敌人的指令等等. cocos2dx为我们提供了定时器schedule相关的操作.其操 ...