IllegalArgumentException"path mu

2018-04-02  本文已影响0人  Sunny君907

关于谷歌play的图标背景为黑色问题

/*Bitmap.Config config =

                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888

                        : Bitmap.Config.RGB_565;*/

        Bitmap.Config config = Bitmap.Config.ARGB_4444;

当报错if (!convexPath.isConvex()) throw new IllegalArgumentException("path must be convex");

将drawable改为bitmap即可

public static Bitmap getBitmapFromDrawable(@NonNull Drawable drawable) {

        final Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

        final Canvas canvas = new Canvas(bmp);

        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());

        drawable.draw(canvas);

        return bmp;

    }

将icon.setBackground 改成icon.setImageBitmap

上一篇下一篇

猜你喜欢

热点阅读