What is the / attr / drawable style for the background?

I am trying to create an ExpandableListView where group headers are reversed. No problem changing text color, size, etc. Through XML. I even found out how to use system defaults like

<TextView  xmlns:android="http://schemas.android.com/apk/res/android"
    style="@android:style/TextAppearance.Medium.Inverse"
/>

But for the background color ?! I don’t understand why these styles do not include background color information ?!

Of course, I could use a direct color, but I'm looking for good default attributes or background styles. Like "style / Background.For.TextAppearance.Medium.Inverse"; -)

What would be a good solution? So for dark theme devices I get white / gray color, and for white theme I get black?

Or should I just use R.color.background_light?

Cheers, Jörg

PS: The first question is here ;-) Thanx to all the people who answer here in recent months and years: you great people made it much easier for me to find a re-entry into programming after a 12 year break; -)

+5
source share
2 answers

As you can see, styles with "TextAppearance" in their name only affect the attributes of the foreground text of the view. They are suitable for the attribute android:textAppearance. Styles with "Widgets" in their names define all the properties of the user interface and will work in the attribute style, but Android does not define the Widget.TextView.Inverse style.

When I wanted to display the console log as a reverse text view, I used the following XML:

<TextView
    android:textAppearance="@style/TextAppearance.AppCompat.Small.Inverse"
    android:background="?android:colorForeground"
    ... />

. , .

0

, TextView, . ,

android:backround="#FFFFFF"

, , #FFFFFF . , :

android:background="@color/my_color_choice"

: - xml Android

, , , TextView ViewGroup (LinearLayout, RelativeLayout) ViewGroup.

-1

All Articles