android上的白色背景和黑色文本颜色穿app

时间:2016-04-19 06:37:44

标签: android wear-os android-theme

在我的Android应用程序中,我需要将默认的黑色背景更改为白色,将文本颜色更改为黑色。为了在每次创建新的布局文件时都不设置这些颜色,我创建了一个定义背景和文本颜色的主题并将其应用到主布局文件

布局文件:

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

样式文件:

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

我附上后,背景变为白色,但文字颜色仍为白色。我做错了什么?为什么我的文字颜色不像我期望的那样黑?

1 个答案:

答案 0 :(得分:0)

在我将主题设置在清单的应用程序标记内之后,它才起作用。

相关问题