White bitmap in Android

I want to set my home wallpaper with a white bitmap:

    Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(0xfff);

    WallpaperManager wall = WallpaperManager.getInstance(this);
    try {
        wall.setBitmap(bitmap);
    } catch (IOException e) {
        e.printStackTrace();
    }

The wallpaper is black. What's wrong with that?

resolvent:

My first guess is your color selection, assuming that this is the value in your actual code, not editing

The color integer in Java adopts ARGB format, so color.white is 0xFFFFFFFF, color.blue is 0xff0000ff, etc

The color (0xfff) in the code will be expanded to 0x00000fff. Blue is mixed with a little green, but the alpha channel is zero. Therefore, canvas is basically written in transparent color

If you use standard colors, I will insist on using constants in the color class as parameters, but if you want to define colors yourself, remember to place full colors or use canvas. Drawrgb()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>