Android PNG gradient background image distortion

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.