Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The meaning of android:colorForeground

Tags:

android

themes

I'm writing a new theme by copying parts from the builtin Theme.Light, and I don't understand what android:colorForeground means.

The only info I could find is "Default color of foreground imagery" here but I still can't understand what it means.

Can someone please enlighten me?

The layout I use for testing:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:colorForeground="#80ff8000" >

    <EditText 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="First EditText"
        android:colorForeground="#ffffffff" />
    <TextView
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="First TextView"
        android:colorForeground="#ff000000" />

    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:colorForeground="#ffffffff" >
        <EditText
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:text="Second EditText, inside a RelativeLayout"
            android:colorForeground="#ff0000ff"
            android:layout_alignParentTop="true"
            android:layout_marginTop="10dip" />
        <TextView
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:text="Second TextView, inside a RelativeLayout"
            android:colorForeground="#ff00ff00"
            android:layout_alignParentTop="true" />
    </RelativeLayout>
</LinearLayout>
like image 218
Radu Avatar asked May 14 '11 21:05

Radu


People also ask

What is colorControlActivated?

attr/colorControlActivated The color applied to icons/controls in their activated state (e.g. checked).

What is windowIsFloating?

android:windowIsFloating is used to indicate whether the current window is floating or not. android:backgroundDimEnabled is used to indicate whether the dimming behind the window is enabled or not.


1 Answers

You can see a sample of usage of "android:colorForeground" in SwitchCompat styling:

styled SwitchCompat

the style (theme) for it:

<style name="MySwitch" parent="Theme.AppCompat.Light">  
    <!-- active thumb & track color (30% transparency) -->
    <item name="colorControlActivated">@color/indigo</item>

    <!-- inactive thumb color -->
    <item name="colorSwitchThumbNormal">@color/pink</item>

    <!-- inactive track color (30% transparency) -->
    <item name="android:colorForeground">@color/grey</item>
</style> 

and applying:

<android.support.v7.widget.SwitchCompat  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="true"
    android:theme="@style/MySwitch"/>

As you can see, "android:colorForeground" determine inactive track color of SwitchCompat.

"MySwitch" theme extends some activity theme ("Theme.AppCompat.Light") and "android:colorForeground" was overrided to change some default value from the activity theme.

So it's a sample of "android:colorForeground" use. Probably there is not the only meaning..

This is the sample link: http://www.materialdoc.com/switch/

like image 119
alexshr Avatar answered Nov 15 '22 20:11

alexshr