nine patch图片的用法绘制以及作用

问题:

今天从网上down下了一个eclipse下的项目,导入到androidStudio中后,结果出现了如下异常:

D:\myAllProject\androidstudio_ajlast\321Browser\uCBrowser_1113\src\main\res\layout\above_slidingmenu.xml
Error:(111, 30) No resource found that matches the given name (at 'src' with value '@drawable/menubar_tabcenter_d').

Error:(20, 38) No resource found that matches the given name (at 'src' with value '@drawable/url_progress_fullscreen').
D:\myAllProject\androidstudio_ajlast\321Browser\uCBrowser_1113\src\main\res\drawable\search_btn_bg.xml
Error:(5, 87) No resource found that matches the given name (at 'drawable' with value '@drawable/search_engines_switcher_item_bg_p').
Error:(6, 87) No resource found that matches the given name (at 'drawable' with value '@drawable/search_engines_switcher_item_bg_p').
Error:Execution failed for task ':uCBrowser_1113:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'F:\programer\android_sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

纠结了很久发现都是.9图片的问题,于是按照网上说的在android的gradle中android标签下加入下面代码,避免了对 .9图片的检查

aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false

然而会继续报错,原因是图片上的像素定位点没有添加,最后还是一个一个改的。

问题核心:

.9图片可以根据ps绘制,同时,android里面也有专门的绘制工具。
.9图片区别于普通图片主要是通过两点:
1.特殊的扩展名,供专门的应用识别
2.图片上下左右4个特殊的黑色像素条,宽一个像素,也可以仅仅是一个点,其中上边和左边像素条标记的分别是图片在横向和纵向的可拉伸区域,至于右边和下边的像素条,网上说是表示“前景能显示的范围”,用了这么久,没见过可以区别的效果,所以也不大理解是什么意思。

Loading Disqus comments...
Table of Contents