gpt4 book ai didi

android - android :colorForeground的含义

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:06 30 4
gpt4 key购买 nike

我正在通过复制内置 Theme.Light 的部分内容来编写一个新主题,但我不明白 android:colorForeground 是什么意思。

我能找到的唯一信息是“前景图像的默认颜色”here但我还是不明白这是什么意思。

谁能教教我吗?

我用于测试的布局:

<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>

最佳答案

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

styled 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>

并申请:

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

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

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

所以这是“android:colorForeground”使用的示例。大概意思不止一个..

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

关于android - android :colorForeground的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6004804/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com