android:colorForeground的含义

Rad*_*adu 9 android themes

我正在通过复制内置Theme.Light中的部分来编写新主题,而我不明白android:colorForeground的含义.

我能找到的唯一信息是"前景图像的默认颜色" ,但我仍然无法理解它的含义.

有人可以赐教吗?

我用于测试的布局:

<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>
Run Code Online (Sandbox Code Playgroud)

ale*_*shr 1

您可以在 SwitchCompat 样式中查看“android:colorForeground”的使用示例:

SwitchCompat 风格

它的风格(主题):

<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> 
Run Code Online (Sandbox Code Playgroud)

并应用:

<android.support.v7.widget.SwitchCompat  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="true"
    android:theme="@style/MySwitch"/>
Run Code Online (Sandbox Code Playgroud)

如您所见,“android:colorForeground”确定 SwitchCompat 的非活动轨道颜色。

“MySwitch”主题扩展了一些活动主题(“Theme.AppCompat.Light”),并且“android:colorForeground”被覆盖以更改活动主题的一些默认值。

这是“android:colorForeground”使用的示例。可能没有唯一的意义..

这是示例链接: http: //www.materialdoc.com/switch/