Android-自己定义图像资源的使用(1)
Android-自己定义图像资源的使用
- 普通图像资源
- XML图像资源
- Nine-patch图像资源
- XML Nine-patch图像资源
- 图层(Layer)图像资源
- 图像状态(state)资源
- 图像级别(Level)资源
- 淡入淡出(transition)资源
- 嵌入(Inset)图像资源
- 剪切(Clip)图像资源
- 比例(Scale)图像资源
- 外形(Shape)图像资源
普通图像资源的使用
<?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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" /> </LinearLayout>
效果图:
xml图像资源的使用
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@[package:]drawable/drawable_resource"
android:antialias=["true" | "false"]
android:dither=["true" | "false"]
android:filter=["true" | "false"]
android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"]
android:mipMap=["true" | "false"]
android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />
这里我不会给大家一个个介绍是什么意思,希望童鞋们自己去官网查看。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/logo"
android:tileMode="repeat" > </bitmap>
这里用到一张图片,设置平铺模式为反复:
Nine-patch 图像资源的使用(重要)
<?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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/res" /> <ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/res" /> <ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/nine_patch" /> </LinearLayout>
效果图例如以下:
XML Nine-Patch 图像资源的使用
<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="false"
android:src="@drawable/nine_patch" > </nine-patch>
<?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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/xml_ninepatch" /> </LinearLayout>
效果图例如以下:
图层资源的使用
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item>
<bitmap
android:gravity="center"
android:src="@drawable/logo" />
</item>
<item
android:left="10dp"
android:top="10dp">
<bitmap
android:gravity="center"
android:src="@drawable/logo" />
</item>
<item
android:left="20dp"
android:top="20dp">
<bitmap
android:gravity="center"
android:src="@drawable/logo" />
</item> </layer-list>
/05_KindOfDrawableUse/res/layout/layer_res.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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/layers" /> </LinearLayout>
效果图例如以下:
本篇博客就介绍这几种图像资源,下篇博客继续介绍,不想让各位一口吃掉一个胖子。
Android-自己定义图像资源的使用(1)的更多相关文章
- Android资源之图像资源(图层图像资源)
曾经看别人的程序的drawable目录里有xml资源,说实话第一次见到这种xml图像资源时,我真心不知道是干什么的.抽出时间学习了一下图像资源.才了解了这类图像资源的妙用. 以下我来分享一下这部分知识 ...
- Android-用你自己的自定义图像资源(2)
Android-自己定义图像资源的使用 2014年4月29日 上一篇博客.介绍前面几种图像资源的使用,本篇博客把剩下的所有介绍完: 普通图像资源 XML图像资源 Nine-patch图像资源 XM ...
- Android资源之图像资源(图像级别资源)
图像状态资源仅仅能定义有限的几种状态. 假设须要很多其它的状态,就要使用图像级别资源. 在该资源文件里能够定义随意多个图像级别. 每一个图像级别是一个整数区间,能够通过ImageView.setIma ...
- Android自己定义控件——3D画廊和图像矩阵
转载请注明出处:http://blog.csdn.net/allen315410/article/details/39932689 1.3D画廊的实现 我们知道android系统已经为我们提供好了一个 ...
- Android资源之图像资源(状态图像资源)
在上一篇博文中.我主要解说了XML图像资源中的图层资源,在此图像资源博文中我会给大家陆续解说XMl图像资源的图像状态资源.图像级别资源.淡入淡出资源.嵌入图像资源.剪切图像资源和外形资源. 1.图像状 ...
- Android自己定义控件而且使其能够在xml中自己定义属性
为什么要自己定义View android开发中自己定义View的优点是显而易见的.比方说以下的这个顶部导航,它被设计出如今应用的每一个界面,但每次的内容却不尽同样.我们不能在每一个layout资源中都 ...
- Android开发 ---如何操作资源目录中的资源文件2
Android开发 ---如何操作资源目录中的资源文件2 一.颜色资源管理 效果图: 描述: 1.改变字体的背景颜色 2.改变字体颜色 3.改变按钮颜色 4.图像颜色切换 操作描述: 点击(1)中的颜 ...
- Android <Android应用开发实战> 资源类型<一>
1.字符串资源>>1.普通字符串>>2.字符串数组 <resources> <string-array name="planets_array&qu ...
- android学习笔记32——资源
Android应用资源 资源分类: 1.无法直接访问的原生资源,保存于asset目录下 2.可通过R资源清单类访问的资源,保存于res目录下 资源的类型以及存储方式 android要求在res目录下用 ...
随机推荐
- ecshop安装程序源码阅读-安装脚本(1)
定义系统判断常量 引入安装初始化文件 设置时区 报告所有错误 定义站点根常量 定义php自身相对路径 引入系统,公共函数库 引入并初始化错误处理对象 引入并初始化模板引擎 引入安装相关业务 发送HTT ...
- 什么XSS攻击?PHP防止XSS攻击函数
什么XSS攻击?PHP防止XSS攻击函数 发布时间: 2013-05-14 浏览次数:22325 分类: PHP教程 XSS 全称为 Cross Site Scripting,用户在表单中有意或无意输 ...
- linux无法umount解决方案
[root@995120-master ~]# umount /drbd/ umount: /drbd: device is busy.(In some cases useful info about ...
- linux系统下,递归删除.svn文件
linux系统下,递归删除.svn文件 SVNLinux 进入要删除的目录,执行下面的命令就可以啦. find . -name "*.svn" | xargs rm -rf
- IE8,IE9,IE10绿色版,以及ColorPix
对于开发者而言IETest是一坨屎. 但是我们终于迎来的蛋糕和火腿,今天无意间发现了竟然有绿色版的浏览器版本,IE9,IE10已经下到本地,IE8网传是有的,但是没有找到合适的版本.但是足够了,本机使 ...
- 外包如何安排人手-b
前几天跟一位做人事的朋友聊天,说起软件行业人员问题.朋友的公司是做软件外包的.一个APP项目基本配置6-7个人,每个Android.ios.后台都各配2人以上,但是项目各种超期.各种无法交付.各种客户 ...
- c++/MFC 封装好的文件内存映射类
整理日: 2015年2月16日 首先介绍内存映射文件操作------函数的用法以及先后执行顺序 // 第一步:创建文件 HANDLE hFile = CreateFileForMapping(_T(& ...
- 消息队列msmq
http://q.cnblogs.com/q/26895/ 远程队列必须现在运程服务器上创建. 在 Windows Server 2008 上安装 IIS 服务和 MSMQ 功能后,系统会在 IIS ...
- Phonegap 3.0 设置APP是否全屏
Phonegap 3.0 默认是全屏,如需要取消全屏,可手动修改config, 在APP/res/xml/config.xml文件可设置preference: <?xml version='1. ...
- 在Windows下读取Ext4分区
转自在Windows下读取Ext4分区 本文介绍两个能在 Windows 下读取ext4分区的软件. 第一个是 Ext2Read.它能查看 ext2/3/4 分区并从中拷贝文件和目录,支持 LVM2 ...