我想创建一个自定义的搜索栏。与其他资源一起,我遵循了这两个示例:
http://developer-dot-android.blogspot.ro/2012/03/custom-seekbar-tutorial.html
http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/
http://code.google.com/p/android-apktool/wiki/9PatchImages
我尝试的所有内容都在这一行崩溃:
........
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/whitepatch">
</nine-patch>通过以下方式:
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #5: <nine-patch> requires a valid 9-patch source image
04-16 15:46:45.242: E/AndroidRuntime(20508): at android.graphics.drawable.NinePatchDrawable.inflate(NinePatchDrawable.java:320)
04-16 15:46:45.242: E/AndroidRuntime(20508): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
04-16 15:46:45.242: E/AndroidRuntime(20508): at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:165)
.....我尝试使用sdk中的draw9patch.bat工具以described here.的形式生成我自己的9补丁图像(没有任何其他解决方法,因为我不知道如何使用,只需导入.png,然后将其保存为.9.png)。
我尝试将第一个教程中使用的whitepatch.9.png复制/粘贴到我的项目中。同样的结果。我真的不知道该怎么做。请帮帮我!

发布于 2013-04-16 21:34:16
九补丁图像是扩展名为9.png的PNG图像。Nine Patch图像包含有关可缩放区域(顶部和左侧)和内容区域(右侧和底部)的元信息。你必须提到强制性的可缩放区域,在顶部和左侧标记1像素(黑色),不包括在缩放时扭曲的角落,否则Android不会将其识别为Nine Patch Image。
下面的链接会更有帮助
http://radleymarx.com/blog/simple-guide-to-9-patch/
http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
https://github.com/chrislondon/9-Patch-Image-for-Websites/wiki/What-Are-9-Patch-Images
http://www.androiddom.com/2011/05/android-9-patch-image-tutorial.html
https://stackoverflow.com/questions/16038174
复制相似问题