Search code examples
androidwear-osandroid-theme

white background and black text color on android wear app


in my android wear app i need to change the default black background to white and the text color to black. in order to not set those colors each time i create a new layout file, i created a theme that defines the background and text color and applied it to the main layoutfile

the layout file:

<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/watch_view_stub"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:roundLayout="@layout/round_activity_wear"
    app:rectLayout="@layout/rect_activity_wear"
    tools:context="com.example.wear.WearActivity"
    tools:deviceIds="wear"
    style="@style/AppTheme">
</android.support.wearable.view.WatchViewStub>

the style file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="android:background">#FFFFFF</item>
        <item name="android:text">#000000</item>
        <item name="android:color">#000000</item>
        <item name="android:colorForeground">#000000</item>
        <item name="android:textColor">#000000</item>
        <item name="android:textColorPrimary">#000000</item>
        <item name="android:textColorSecondary">#000000</item>
        <item name="android:textAppearance">@style/WearTextAppearance</item>
    </style>

    <style name="WearTextAppearance" parent="@android:style/TextAppearance.Medium">
        <item name="android:color">#000000</item>
        <item name="android:colorForeground">#000000</item>
    </style>
</resources>

after i attached it, the background changed to white, but the text color remained white. what did i do wrong? why is my text color not black as i would expect it?


Solution

  • it worked after i set my theme inside the application tag of the manifest.