Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android rendering shade of blue wrong on some devices

Tags:

I'm running an app on various devices and on two a certain shade of blue looks wrong. Please see the attached image. Any ideas why that is? If I replace the color with a different one without any other changes, everything looks fine. enter image description here

EDITOR's NOTE: Original poster states that there is a single colors.xml file in the project's resources and the color is defined once. The color is defined by a name (@color/pbr) and has a value of #447AD4. The layout for the screenshots above uses the same resource name throughout, but renders as different colors.

like image 303
vera Avatar asked Sep 22 '15 17:09

vera


People also ask

What color formats are supported for color resources in Android?

red(int) to extract the red component. green(int) to extract the green component. blue(int) to extract the blue component.

What is a selector Android?

A selector may be created by invoking the open method of this class, which will use the system's default selector provider to create a new selector. A selector may also be created by invoking the openSelector method of a custom selector provider. A selector remains open until it is closed via its close method.


1 Answers

So this looks like an issue with tintMode. The reason the colors look different is the transparency. By default, Drawables in Android have a tintMode of SRC_IN, meaning they will keep their color but use the alpha of whatever is underneath them during rendering. From the looks of it, there are views underneath the blue ones that are not 100% opaque.

To solve this you could explicitly set the tintMode to something like SRC_OVER which will keep the alpha you set intact. The other option is instead of setting at the background to a color, set it to a Shape Drawable with a solid fill. That will make sure that the view is opaque and will have a consistent color.

like image 83
SeanA Avatar answered Nov 03 '22 15:11

SeanA