I have a simple DialogFragment which shows a bit of text (which contains a Year string) and then a SeekBar that the user can slide and change the Year string.
On Android 3 and 4 this looks right... those platforms have a light background and use black text.
However, on Android 2, the dialog has a dark background and is still using black text.
I don't want to have to configure different color schemes for different versions of Android because there has GOT to be some default values built into the Android system that I should be able to use to style my TextView so that it uses the appropriate text color.
Here is my TextView that displays the year string:
<TextView
android:id="@+id/textViewYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="1976"
android:textAppearance="?android:attr/textAppearanceLarge" />
What settings can I apply to my TextView so that it will always be appropriately colored by the system?
Note, I can't just use an Inverse style, because on Android 3 and 4 it is working properly. If I use an Inverse text appearance then it works on Android 2, but fails on 3 and 4.
I found the solution on another SO post:
builder.setInverseBackgroundForced(true)
On Android 3.x and 4.x this doesn't seem to change anything, but on Android 2.x it inverts the color scheme so that the background is white so the black text shows up properly.
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