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 ...
随机推荐
- 一款简洁的纯css3代码实现的动画导航
之前为大家介绍了好多导航菜单,今天给大家分享一款简洁的纯css3代码实现的动画导航.鼠标经过的时候以背景色以菱形渐变为长方形.效果图如下: 在线预览 源码下载 实现的代码. html代码: < ...
- 分享JQuery动画插件Velocity.js的六种列表加载特效
分享JQuery动画插件Velocity.js的六种列表加载特效.在这款实例中给中六种不同的列表加载效果.分别为从上飞入.从右侧飞入.从左侧飞入.和渐显.一起看下效果图: 在线预览 源码下载 实现 ...
- zookeeper原生API做java客户端
简介 本文是使用apache提供的原生api做zookeeper客户端 jar包 zookeeper-3.4.5.jar Demo package bjsxt.zookeeper.base; im ...
- 【Unity笔记】给UGUI元素添加交互性
如果想给UGUI元素添加交互性,如使一张图片能够被点击,具有normal.Highlighted.Pressed三态,可以给该物体添加组件Selectable. 已经具有交互性的物体不能再添加Sele ...
- SpringMVC HandlerMethodArgumentResolver自定义参数转换器 针对HashMap失效的问题
自定义Spring MVC3的参数映射和返回值映射 + fastjson 自定义Spring MVC3的参数映射和返回值映射 + fastjson首先说一下场景:在一些富客户端Web应用程序中我们会有 ...
- Apache HttpComponents 获取页面内容String方式
/* * ==================================================================== * Licensed to the Apache S ...
- u-boot可ping通PC,PC不可ping通u-boot
http://blog.csdn.net/ce123_zhouwei/article/details/7339134 开发板运行U-Boot,在终端下使用Ping命令是能Ping通PC机,但PC机Pi ...
- C#递归累计到父行
搞了半天 写了一个算法,希望能帮到需要的朋友 效果如下 水电费用是由 就是部门水费和电费累加的,而部门水费由科室水费累加起来的 表结构 DataTable dt = new DataTable(); ...
- linux取随机数shell版本
#!/bin/bash aa=$(-) ..} do useradd $i echo $aa|passwd --stdin $i echo "${i} ${aa}" >> ...
- Timsort 算法
转载自:http://blog.csdn.net/yangzhongblog/article/details/8184707 Timsort是结合了合并排序(merge sort)和插入排序(inse ...