Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blue Holo colors appear green on device

Tags:

android

colors

I'm facing a weird issue where I'm setting the background of a TextView to @android:color/holo_blue_bright, expecting it to be bright blue, only to find that it's some kind of bright green on a device.

XML

<TextView
    android:id="@+id/tv_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:background="@drawable/chat_bubble"
    android:maxWidth="300dp"
    android:padding="5dp"
    android:singleLine="false"
    android:textSize="16sp" />

@drawable/chat_bubble

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/chat_bubble_background" />

    <corners android:radius="5dp" />
</shape>

colors.xml (just the relevant line)

<color name="chat_bubble_background">@android:color/holo_blue_bright</color>

Above settings produce this. Each message is a TextView

enter image description here

I thought maybe it was because my device displays colors differently or something, so I tried some more holo colors, but they all look exactly as they should

@android:color/holo_green_light gives

enter image description here

@android:color/holo_green_dark gives

enter image description here

Even @android:color/holo_orange_light and @android:color/holo_purple look OK

enter image description here

enter image description here

except for the blue ones:

@android:color/holo_blue_light gives

enter image description here

@android:color/holo_blue_dark gives

enter image description here

All blue appear as similar, but not exactly the same tints of green. Also not the same tint of green as holo_green_light or holo_green_dark.

I thought what is this? Everything looks good, but not blue? and went to check what the HEX of holo_blue_bright is and I found it here (it's #FF00DDFF).
So I tried to use that HEX values directly, instead of using the predefined holo color.

enter image description here

Android studio (v1.2) tells me they are exactly the same color, as I expected.

However, when I then changed

<solid android:color="@color/chat_bubble_background" />

to

<solid android:color="@color/chat_bubble_background2" />

to use #FF00DDFF as color, I got this

enter image description here

Which is exactly what I expected to see when I was using holo_blue_bright! Which should makes sense, considering they're the same color.

I'm stumped. What is going on here, what am I missing? Why do 2 supposedly equal color codes produce different results, and why are all the other holo colors looking normal?


Device info:

OnePlus One
Model A0001
Running Cyanogen OS v11.0-XNPH05Q / kernel 3.4.0-cyanogenmod-gc73a4ec build 04
Running Android 4.4.4

like image 640
Tim Avatar asked Apr 10 '15 16:04

Tim


2 Answers

The hexcode for holo_blue_bright in the standard Android 4.4.4 is ff00ddff (Source).

The green color that you get is actually the value of user_icon_6, which is described as "light green 500" (Source).

It looks like the manufacturer of your device customized the color palette by replacing the default values with other colors (intentional or not). This means that holo_blue_bright is defined like this in your customized Android version:

<color name="holo_blue_bright">#ff8bc34a</color>


Now that you provided device information, I looked up the source of CM11. The color defined is ff00ddff, which is correct. However, OnePlus develops their own version of Cyanogen OS, so they may have changed the values for the colors. Sadly, I couldn't find the source code for CM11-XNPH05Q, so I can only guess.

I suggest you to ask OnePlus directly about this issue.

like image 188
Manuel Allenspach Avatar answered Sep 24 '22 02:09

Manuel Allenspach


From your comment above

@CSmith It gives me ff8bc34a, which looks like the kind of green I'm seeing. Why does Android Studio tell me it's ff00ddff then?

it is pretty clear that the manufacturer has changed the color on the device. Android Studio gives you the color value from the official android resources in the SDK.

Try your app in an emulator with e.g. Nexus 5. I bet the color will be correct there.

like image 41
Ridcully Avatar answered Sep 25 '22 02:09

Ridcully