How to make 9-patch image downloaded from the Network
Probably everyone, who is in touch with the Android world dealt with 9-patch term. It is an image in PNG format, enhanced by the ability to define zones for the enlargement or reduction or the zone in which should be the future content. It is very useful feature considering different resolution and pixel density, big fragmentation of devices with OS Android and screen sizes variability (see the example http://on.fb.me/1eRFVjW). New Android version 4.3 has possibility to define the borders of the picture even for his alignment with surrounding (seehttp://bit.ly/16S47zZ).
In practice it is working that around the default image is drawn one-pixel transparent border. In this frame are with black colour on top left signed areas which should repeat or miss depending on the image future flexibility – expansion or shrinking. In down right part of the frame is signed area where should be placed the future content.

The Tool Draw 9-patch is done for easy making 9-patch images and is a part of Android SDK (can be found on address book \android-sdk\tools\). Tool creates a file with 9.png suffix, which you can use straight in your project. But this is working so far you do not decide that the image will not be a part of the project, but will be downloaded from server after switching on application. The reasons for this are changes of graphical interface which user can maintain alone or without necessity repeatedly setting up application and its placing on application shops Google Play or SamsungApps.
If the 9-patch image suffix is recognized during setting up application the file is additionally compiled. This recognition run only in address book drawable and Android will correctly show only pictures which had been changed this way. Therefore you cannot use images downloaded from the server, which are output from Draw 9-patch or other graphics editor. Images for downloading can be of course manually copied from created apk archive, but this solution is heavy. There is much quicker way how to process 9-patch images, separately or together, from the command line using the Android Asset Packaging Tool (aapt):
aapt c[runch] [-v] -S input-folder -C output-folder
aapt s[ingleCrunch] [-v] -i input-file -o output-file
After downloading the file is no need to change anything, class BitmapFactory will proceed it alone. To verify whether it is indeed a 9-patch image you can make the following checks:
Bitmap bitmap = BitmapFactory.decodeStream(stream);
byte[] chunks = bitmap.getNinePatchChunk();
boolean result = NinePatch.isNinePatchChunk(chunks);
How to make 9-patch image downloaded from the Network的更多相关文章
- Relinking Oracle Home FAQ ( Frequently Asked Questions) (Doc ID 1467060.1)
In this Document Purpose Questions and Answers 1) What is relinking ? 2) What is relinking ...
- 在 ML2 中配置 OVS flat network - 每天5分钟玩转 OpenStack(133)
前面讨论了 OVS local network,今天开始学习 flat network. flat network 是不带 tag 的网络,宿主机的物理网卡通过网桥与 flat network 连接, ...
- robotframework笔记1
机器人框架是一个基于Python的,可扩展的关键字驱动的自动化测试最终到终端的验收测试和验收测试驱动开发(ATDD)框架.它可用于检测分布式异类应用程序,其中,验证要求感人几种技术和接口. 下面列出了 ...
- Chrome的开发者工具(Chrome Developer Tools)
Chrome的开发者工具(Chrome Developer Tools) 按F12 https://developer.chrome.com/devtools/index http://www.w3s ...
- Robotframework 3- 安装
1. 安装, python3 安装好后,在cmd中运行 pip install robotframework # Install the latest version (does not upgrad ...
- How to get the MD5 checksum for a file: md5sum, digest, csum, fciv
LINUX: md5sum fileName In Linux, the md5sum utility can be used: aemtux1:/ % md5sum binary.file 0c46 ...
- (转载)Universal Correspondence Network
转载自:Chris Choy's blog Universal Correspondence Network In this post, we will give a very high-level ...
- Java基础之类加载器
Java类加载器是用户程序和JVM虚拟机之间的桥梁,在Java程序中起了至关重要的作用,理解它有利于我们写出更优雅的程序.本文首先介绍了Java虚拟机加载程序的过程,简述了Java类加载器的加载方式( ...
- LPC18xx LPC43xx LPC4370 Bootrom USB DFU FPB - Flash Patch and Breakpoint Unit
What is the difference between a Bootrom vs bootloader on ARM systems Bootrom Bootrom (or Boot ROM) ...
随机推荐
- 二十种实战调优MySQL性能优化的经验
二十种实战调优MySQL性能优化的经验 发布时间:2012 年 2 月 15 日 发布者: OurMySQL 来源:web大本营 才被阅读:3,354 次 消灭0评论 本文将为大家介 ...
- SQL Server 日期的加减函数: DATEDIFF DATEADD
SQL Server 日期的加减函数: DATEDIFF DATEADD DATEDIFF: 返回跨两个指定日期的日期边界数和时间边界数, 语法:DATEDIFF ( datepart , st ...
- linux jdk+mysql+tomcat+nginx 项目部署步骤
1.下载linux jdk1.7.0_79.tar.gz ; 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-dow ...
- js下的sleep实现
function sleep(d){ for(var t = Date.now();Date.now() - t <= d;); } sleep(5000); //当前方法暂停5秒
- DW(六):polybase访问Azure Blob Storage
目录: 连接hadoop配置语法 配置hadoop连接 Pushdown配置 Create external tables for Azure blob storage 连接hadoop配置语法: g ...
- [转]wireshark 实用过滤表达式(针对ip、协议、端口、长度和内容)
首先说几个最常用的关键字,“eq” 和 “==”等同,可以使用 “and” 表示并且,“or”表示或者.“!" 和 "not” 都表示取反. 一.针对wireshark最常用的自然 ...
- 【Java编程进阶-1】enum枚举的使用
枚举主要用于枚举常量,下面举个简单的应用. 比如一个公司有如下几个部门: 研发部: 销售部: 财务部: (其他部门暂时不列举) 部门的某些信息相对固定,此时可以考虑使用枚举来说明: 枚举类 Depts ...
- android学习笔记九——RatingBar
RatingBar==>星级评分条 RatingBar和SeekBar十分相似,它们甚至有相同的父类:AbsSeekBar.两者都允许用户通过拖动来改变进度: 两者最大的区别在于RatingBa ...
- No Suitable Driver Found For Jdbc_我的解决方法
转载自:http://www.blogjava.net/w2gavin/articles/217864.html 今天出现编码出现了No suitable driver found for ...
- Makefile编译选项CC与CXX/CPPFLAGS、CFLAGS与CXXFLAGS/LDFLAGS
转自:http://www.firekyrin.com/archives/597.html 编译选项 让我们先看看 Makefile 规则中的编译命令通常是怎么写的. 大多数软件包遵守如下约定俗成的规 ...