2

Currently, I'm using theme Theme.Sherlock.Light.DarkActionBar.

I'm applying ?android:attr/textAppearanceMedium and ?android:attr/textAppearanceSmall attributes, for the TextView used in ListView

<TextView
    ...
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    ...
    android:textAppearance="?android:attr/textAppearanceSmall" />

However, for Jelly Bean and Gingerbread, I get 2 very different effects.

Jelly Bean (Looks great!)

enter image description here

Gingerbread (Ergh...)

enter image description here

Is there any portable way I can tell, when using textAppearanceMedium and textAppearanceSmall attributes on a light background, the color should be dark. Currently, Gingerbread is using light background for its list view. Hence, the correct font color should be dark, so that text is visible.

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
  • Is the dropdown list view with both TextViews completely custom? If so, why don't you just change the background color of it to a dark tone? – saschoar Apr 01 '13 at 22:01
  • Yes. The background color is changable to dark tone and it is one of the solutions. Just that, how can I maintain the default background color provided by system, yet able to make my text color visible, without any hard coding (Says, fix font color for Gingerbread must be dark)? In another word, the font attribute will realize its current background, and use correct color accordingly. – Cheok Yan Cheng Apr 02 '13 at 01:27
  • I understand what you are planning. Please see my extended answer below (too long for a comment). – saschoar Apr 02 '13 at 12:32

1 Answers1

0

I understand that you want to support the native look of the respective Android version and want to avoid overwriting default colors.

A "vanilla" Gingerbread version might look like the one in your screenshot, but I have also seen GUI adaptations of device manufacturers (such as Samsung TouchWiz or HTC Sense) or Custom ROMs overwriting these color values. Not only the default background colors, also text colors.

In consequence, you cannot be sure that all pre-Honeycomb versions show bright text on a white background in dropdowns, so you'd have to check the text color as well and adapt it accordingly. Checking background or foreground resources/colors of a view can be very cumbersome, but here are two approaches: https://stackoverflow.com/a/8089242/1140682 and https://stackoverflow.com/a/8848494/1140682

However, I highly suggest that you apply custom, "fixed" colors to your text and background. Since the ActionBar has only been introduced with Honeycomb, there are no ActionBar guidelines/styles for previous versions that you could violate anyway. A good start for this is the ActionBar Style Generator that also supports Theme.Sherlock.Light.DarkActionBar. It generates all the drawables and style files for you so that your ActionBar and menus look consistent across multiple Android versions and modifications.

Community
  • 1
  • 1
saschoar
  • 8,150
  • 5
  • 43
  • 46