9补丁不工作 [英] 9-patch not working

查看:287
本文介绍了9补丁不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与Android上的9补丁PNG的奇怪问题。
它已经失败,在Eclipse可视化编辑器,无论哪个目标我使用(试了7和14之间)。
错误日志显示消息的 main.xml中:指数:0,大小:0
例外的背后,是:

I'm having strange issues with 9-patch png's on Android. It already fails in Eclipse visual editor, no matter which target I use (tried several between 7 and 14). The error log shows the message main.xml: Index: 0, Size: 0 The exception behind is:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:185)
at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:101)
at android.graphics.NinePatch_Delegate$1.draw(NinePatch_Delegate.java:219)
at com.android.layoutlib.bridge.impl.GcSnapshot.drawInLayer(GcSnapshot.java:613)
at com.android.layoutlib.bridge.impl.GcSnapshot.draw(GcSnapshot.java:583)
at android.graphics.NinePatch_Delegate.draw(NinePatch_Delegate.java:217)
at android.graphics.NinePatch_Delegate.nativeDraw(NinePatch_Delegate.java:170)
at android.graphics.NinePatch.nativeDraw(NinePatch.java)
at android.graphics.NinePatch.draw(NinePatch.java:120)
at android.graphics.drawable.NinePatchDrawable.draw(NinePatchDrawable.java:189)
at android.view.View.draw(View.java:10865)
at android.view.ViewGroup.drawChild(ViewGroup.java:2899)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.ViewGroup.drawChild(ViewGroup.java:2897)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.ViewGroup.drawChild(ViewGroup.java:2897)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.View.draw(View.java:10883)
at android.view.ViewGroup.drawChild(ViewGroup.java:2899)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.ViewGroup.drawChild(ViewGroup.java:2897)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.View.draw(View.java:10883)
at android.view.ViewGroup.drawChild(ViewGroup.java:2899)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495)
at android.view.View.draw(View.java:10883)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:505)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:324)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1323)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1077)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:903)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(LayoutEditor.java:399)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2746)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

的9补丁与包含在SDK中draw9patch工具创建的。
我有我的所有在这个项目中使用的图像此问题。我已经用在其他项目9个补丁之前没有任何问题,因此假设有具体到我目前的PNG的格式的东西。也许设计师使用Photoshop中创建的PNG的从而导致无效的9补丁。
没有任何人有一个想法有什么问题吗?

The 9-patch was created with the draw9patch-tool included in the SDK. I have this issues with all the images I use in this project. I already used 9-patch before in other projects without problems and thus assume there's something specific to the format of my current png's. Maybe the used Photoshop of the designer creates png's which result in invalid 9-patches. Does anybody have an idea what's the issue here?

更新:

工作版本:

不工作的版本:

推荐答案

似乎是固定在SDK十七分之一十六,在这里看到:

Seems to be fixed in SDK 16 / 17, see here:

HTTP://$c$c.google。 COM / p /安卓/问题/细节?ID = 39814

在这里:

HTTP://$c$c.google。 COM / p /安卓/问题/细节?ID = 37472

这篇关于9补丁不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆