Android PNG gradient background image distortion
14:11:17 | category: Android drawing | font size subscription
A problem that has been plagued for a long time recently occurs when the PNG image of the gradient effect is set to a control image or background, there is no problem in eclipse, but when running on the device, we can see an obvious circle of contour lines, and the picture is seriously distorted.
Google seems to have encountered this problem for many people. One explanation is that the android display uses 16-bits color palette by default to represent all colors, therefore, 32-bit PNG images with Alpha values are distorted.
There are two solutions to this problem:
1. The first method is the simplest and most straightforward (recommended). Set the pixelformat to display the activity,
Getwindow (). setformat (pixelformat. rgba_8888 );
PS: directly add
Rgba_8888 is a 32-bit color format for Android. R, G, B, And a are represented by eight bits. The default format for Android is pixelformat. opaque, which does not contain Alpha values. After the settings, you can see that the image display effect is the same as that on the PC, and there will be no strip line.