2011-06-23 16 views
0

你好,我建一个小部件,它包含的标题和内容分隔 也只是像往常一样,我进口我的图像被拉伸的文件夹错误:无法处理PNG图像的Android

一个imageview的我宣布我的窗口小部件的XML图像布局是这样的:

<ImageView 
    android:id="@+id/img_widget" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="5dip" 
    android:layout_marginBottom="10dip" 
    android:gravity="center_vertical|center_horizontal" 
    android:src="@drawable/divider"/> 

它在我的文件夹绘制 divider.9.png所以,当我开始编译这个事实证明错误 不是在xml文件,但在图像本身

当我看着控制台它说:

ERROR: Failure processing PNG image /home/drikvi/workspace/AnimList/res/drawable-hdpi/divider.9.png 
[2011-06-23 15:18:59 - AnimList] W/ResourceType(2305): Bad XML block: header size 2433 or total size 0 is larger than data size 0 
[2011-06-23 15:18:59 - AnimList] W/ResourceType(2305): Bad XML block: header size 2433 or total size 0 is larger than data size 0 

我真的不知道这个吗?

任何解决方案?

回答

0

我怀疑你的图像不是9-patch,它应该是如果它有.9.png扩展名。尝试将其重命名为divider.png,看看是否有效。

+0

好吧,我已经修补过它...我会试试:) – user724861

+0

好吧,试试我的建议。如果它起作用,那么9贴片格式就有问题。如果仍然失败,那么你的png格式有问题。 –

+0

好吧,它的作品!但我仍然需要9个补丁图像...嗯...好吧,我会重新发布它,谢谢! – user724861

-2
<ImageView  
     android:id="@+id/img_widget"  
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dip"  
     android:layout_marginBottom="10dip" 
     android:gravity="center_vertical|center_horizontal" 
     android:src="@drawable/divider.9"/> 

支票影像名divider.9

+0

如果您使用的是9贴片图像,则不需要为可绘制名称包含.9扩展名。 –

+0

你不能在图像名称中使用.9 –

+0

是的,你可以,只要它是9格式的。但是,您不需要在可绘制的引用名称中包含.9。如果你不相信我,请查看http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch。 –

0

你能尝试以下解决方案..

最初从ImageView的删除src属性...保存XML布局,然后生成项目。之后尝试用户divider.png而不是divder.9.png在资源目录中的3 dpi文件夹中。然后再次替换您在xml布局中注释掉的代码。再次构建..现在应该没有任何问题。