首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.xmlpull.v1.XmlPullParserException:二进制XML文件第5行:< 9-patch >需要有效的9补丁源映像

org.xmlpull.v1.XmlPullParserException:二进制XML文件第5行:< 9-patch >需要有效的9补丁源映像
EN

Stack Overflow用户
提问于 2013-04-16 21:18:43
回答 1查看 2.8K关注 0票数 0

我想创建一个自定义的搜索栏。与其他资源一起,我遵循了这两个示例:

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

我尝试的所有内容都在这一行崩溃:

代码语言:javascript
复制
   ........
  <nine-patch
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:src="@drawable/whitepatch">
  </nine-patch>

通过以下方式:

代码语言:javascript
复制
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复制/粘贴到我的项目中。同样的结果。我真的不知道该怎么做。请帮帮我!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16038174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档