android studio build .9.png格式错误 [英] android studio build .9.png format error

查看:42
本文介绍了android studio build .9.png格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是错误日志:

Error:Execution failed for task ':MobileSafe2:mergeDebugResources'.
Crunching Cruncher call_locate_blue.9.png failed, see logs

但是当我将.9.png扩展名转换为.png时,错误将消失,我不知道为什么会发生.

But when I turn the .9.png extension into .png, the error will disappear, I don't know why it happens.

这是代码:

    public void myToast(String address) {
        View view = View.inflate(context, R.layout.address_show, null);
        view.setBackgroundResource(**R.drawable.call_locate_blue**);

        TextView textView = (TextView) view.findViewById(R.id.tv_address);
        textView.setText(address);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();

        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;

        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        params.format = PixelFormat.TRANSLUCENT;
        params.type = WindowManager.LayoutParams.TYPE_TOAST;
        wm.addView(view, params);
    }​

这在Android Studio中

This is in Android Studio

错误信息:

我必须将'.9.png'修复为'.png',然后它可以工作,但是图片会失真

I have got to fix '.9.png' into '.png', then it can work, but the picture will be distorted

推荐答案

据我所知,您没有放置9 patch markers.
需要这些文件才能将 png 转换为 9.png (正确地称为 9补丁).

As far as I can see, you didn't put the 9 patch markers.
These ones are needed to turn a png into a 9.png (properly said a 9 patch).

没有这些标记,它将是正常图像-但IDE会期望其他内容,因为扩展名告诉您:嘿,我是9个补丁:请正确对待我."

Without those markers, it will be a normal image - but the IDE expects something else, because the extension tells "Hey, I'm a 9 patch: treat me properly".

可以这么说,就好像您买了柠檬水,但里面却发现有苹果汁.

So to speak, it's like if you buy a lemonade, but you find an apple juice inside.

您会在这里找到有关9个补丁的不错的教程: http://blog.booleanbites.com/2012/11/android-how-to-use-9-patch-png.html

Here you'll find a nice tutorial on 9 patches: http://blog.booleanbites.com/2012/11/android-how-to-use-9-patch-png.html

这篇关于android studio build .9.png格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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