Значение андроида: colorForeground - PullRequest
8 голосов
/ 15 мая 2011

Я пишу новую тему, копируя части из встроенного 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>

1 Ответ

0 голосов
/ 03 июня 2017

Вы можете увидеть пример использования «android: colorForeground» в стиле SwitchCompat:

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.

Тема «MySwitch» расширяет некоторые действияТема («Theme.AppCompat.Light») и «android: colorForeground» была переопределена для изменения некоторого значения по умолчанию из темы действия.

Так что это пример использования «android: colorForeground».Возможно, здесь нет единственного значения ..

Это пример ссылки: http://www.materialdoc.com/switch/

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...