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) ...
随机推荐
- C#读写txt文件的两种方法介绍
C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...
- Review Board——在线代码审查工具
代码审查(Code Review)不但可以提高质量,而且还是一个知识共享和指导的极好的手段.不幸的是,准备工作的辛苦和工具支持的缺乏让代码审查很容易被延至“稍后再议”.Review Board的目标便 ...
- HBase(六): HBase体系结构剖析(上)
HBase隶属于hadoop生态系统,它参考了谷歌的BigTable建模,实现的编程语言为 Java, 建立在hdfs之上,提供高可靠性.高性能.列存储.可伸缩.实时读写的数据库系统.它仅能通过主键( ...
- apache 2.4 配置多个站点
1.打开\Apache24\conf\httpd.conf 查找conf/extra/httpd-vhosts.conf 去掉前面的#号,一般是去掉的 2.在httpd.conf 中查找Requir ...
- 对 COM+ 组件进行了方法调用,但该组件有一个已被中止的或正在被中止的事务。 (异常来自 HRESULT:0x8004E003)
错误: 对 COM+ 组件进行了方法调用,但该组件有一个已被中止的或正在被中止的事务. (异常来自 HRESULT:0x8004E003) 解决办法: 程序连接的数据库换到本地. 具体原因没搞 ...
- SQL SERVER XML 学习总结
SQL SERVER XML 学习总结 最新的项目任务要做一个数据同步的功能,这些天都在做技术准备,主要是用到了微软的Service Broker技术,在熟悉使用该技术的同时,又用到了Sql s ...
- openssl与cryptoAPI交互AES加密解密
继上次只有CryptoAPI的加密后,这次要实现openssl的了 动机:利用CryptoAPI制作windows的IE,火狐和chrome加密控件后,这次得加上与android的加密信息交互 先前有 ...
- [转]使用 Minidumps 和 Visual Studio .NET 进行崩溃后调试
本文关键字:Minidumps, Windows, SEH, VisualC, .NET 摘要 本文讲述了 minidumps 是怎样工作的.当你的程序崩溃的时候应该如何生成它们.以及如何在 Visu ...
- PHPWord生成word实现table合并(colspan和rowspan)
PHPWord(http://phpword.codeplex.com/)是一个很好处理和生成WORD文档的工具,但是生成复杂的word,如colspan和rowspan的实现,还是需要你做些修改. ...
- 黄聪:WebBrowser执行和安装jQuery脚本(IEBrowse)
上一文章说明了如何让 js 脚本访问 .NET 中的类, 这次希望给大家说明一下在任意页面中安装 jQuery 脚本, 并操作页面上的元素. 其实在第一篇关于 IEBrowser 的文章当中, 已经有 ...