Probably everyone, who is in touch with the Android world dealt with 9-patch termIt 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的更多相关文章

  1. 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 ...

  2. 在 ML2 中配置 OVS flat network - 每天5分钟玩转 OpenStack(133)

    前面讨论了 OVS local network,今天开始学习 flat network. flat network 是不带 tag 的网络,宿主机的物理网卡通过网桥与 flat network 连接, ...

  3. robotframework笔记1

    机器人框架是一个基于Python的,可扩展的关键字驱动的自动化测试最终到终端的验收测试和验收测试驱动开发(ATDD)框架.它可用于检测分布式异类应用程序,其中,验证要求感人几种技术和接口. 下面列出了 ...

  4. Chrome的开发者工具(Chrome Developer Tools)

    Chrome的开发者工具(Chrome Developer Tools) 按F12 https://developer.chrome.com/devtools/index http://www.w3s ...

  5. Robotframework 3- 安装

    1. 安装, python3 安装好后,在cmd中运行 pip install robotframework # Install the latest version (does not upgrad ...

  6. 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 ...

  7. (转载)Universal Correspondence Network

    转载自:Chris Choy's blog Universal Correspondence Network In this post, we will give a very high-level ...

  8. Java基础之类加载器

    Java类加载器是用户程序和JVM虚拟机之间的桥梁,在Java程序中起了至关重要的作用,理解它有利于我们写出更优雅的程序.本文首先介绍了Java虚拟机加载程序的过程,简述了Java类加载器的加载方式( ...

  9. 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) ...

随机推荐

  1. 如何破解海蜘蛛ISP6.1.5 极其isp运营商 v6.1.5

    海蜘蛛ISPV6.1.5,目前破解版本中最稳定的!破解步骤如下:一.安装完毕进控制台二.使用muddyboot登陆 密码(123456)三.输入root回车四.输入regtools回车五.在web控制 ...

  2. C#颜色和名称样式对照表

    1   Color.AliceBlue 240,248,255 Color.LightSalmon 255,160,122 Color.AntiqueWhite 250,235,215 Color.L ...

  3. Protocol Buffer基本介绍

    转自:http://www.cnblogs.com/stephen-liu74/archive/2013/01/02/2841485.html 该系列Blog的内容主体主要源自于Protocol Bu ...

  4. ajax同步,异步

    传输数据 同步:第一条传过去,对方接收到反馈以后,再传第二条; 异步:第一条传过去,不管对方有没有收到,继续传第二条. ajax(默认异步 async:true) 同步:执行完ajax内部代码,才执行 ...

  5. jQuery网页右侧固定层显示隐藏在线qq客服代码

    CSS代码: @charset "utf-8"; ;;} html,body{font-size:12px;font-family:"微软雅黑";outline ...

  6. Java文件读写

    import java.io.*; public class Study { public static void main(String[] args) { try { String strPath ...

  7. FDATool使用

    1. 幅值有两种单位可选,linear和db.切换单位时Toolbox的图例会跟着变化,可以看出两种单位下参数含义不太一样. 线性坐标:例如设置为0.01/0.01,表示通带幅度0.99~1.01,阻 ...

  8. 发布一个.net mvc站点遇到的问题及解决

    1.先通过vs2012发布.net mvc项目,遇到问题是一路默认下来,提示发布已成功,但对应文件夹里没有任何文件 解决: 第一步,新建了一个文件夹 第二步,在[配置文件]步骤,新建配置文件 第三步, ...

  9. 黄聪:走进wordpress do_action函数

    再看do_action函数.位于plugin.php352行.我把源码放在西街口这里,略去了其它辅助处理的语句. 如下: function do_action($tag, $arg = '') {   ...

  10. 关于 ProcessEngines.getDefaultProcessEngine();NullPointException问题

    查看ProcessEngines的源码发现默认加载的文件名为"activiti.cfg.xml" resources = classLoader.getResources(&quo ...