The meaning of android:colorForeground
I'm writing a new theme by copying parts from the bu开发者_开发知识库iltin 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>
You can see a sample of usage of "android:colorForeground" in SwitchCompat styling:
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/
精彩评论