Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get Android System Colors

I've seen references on how to SET system colours, but I need to find out how you GET them - how do you find out what they are?

On the Samsung Galaxy S for example, the tab views, ListView highlights when you select an item, and the Summary text line on the preference screen are all blue.

There are many apps which immitate this style and I want to do the same. Obviously I cannot just hard code and set the colour to Blue, as other handsets use different colours.

The question is, is there a way to programmatically find out what colour the Preference Screen Summary Line, Tabs, or ListView selections are, so that you can then set that against a TextView elsewhere in your app?

How do I get the android system colours?

like image 869
Simon Avatar asked Nov 16 '10 09:11

Simon


People also ask

How do I change the colors on my Android?

Change the color scheme On your phone, go to the Settings app. Tap Wallpaper & style. To change the color palette of your wallpaper, tap Wallpaper colors and select the color palette you like. To change the color of your tabs to a specific color, tap Basic colors and select the color you like.

What is the color code for Android?

The hexadecimal color code #a4c639 is a shade of yellow-green. In the RGB color model #a4c639 is comprised of 64.31% red, 77.65% green and 22.35% blue. In the HSL color space #a4c639 has a hue of 74° (degrees), 55% saturation and 50% lightness.

How can I change my mobile theme color?

Settings. Under Display Options, tap Theme. Select the theme for this device: Light—White background with dark text.


1 Answers

There is an answer to this question, but it is probably not the one you wanted to hear. There is no way to reliably do this. The "selection color" is actually part of a nine-patch image, which is provided on a platform specific basis. Some use the standard orange color, some (Sense) uses green, and others use red. With an exhaustive list of these you might be able to create a mapping from hardware to color, but this is not very effective because new hardware comes out all the time, and some of these phones allow sense to be uninstalled.

The only real thing you can do is to make your buttons consistent within the application itself, which is a hard enough task by itself. If you really have to have a custom item with a selection color (which is common enough), then my advice would be to copy the button resources from the platform of your choice (I like the default sdk resources myself) and then manually set them throughout your application. This way they will always look the same no matter which platform you are on, and so will always match your custom views. Note that this will require you to do more than just buttons. Dialogs and menus also will need to be modified, which is possible, but hard.

Really this is a flaw in the way Android was designed, and it causes a lot of us grief. I wish I had a better answer for you, but I think this is the best we've got.

like image 89
Micah Hainline Avatar answered Nov 15 '22 15:11

Micah Hainline