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?
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.
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.
Settings. Under Display Options, tap Theme. Select the theme for this device: Light—White background with dark text.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With