2016-04-19 72 views
1

在我的android穿应用程序我需要将默认的黑色背景更改为白色和文本颜色黑色。为了每个我创建一个新的布局文件时不设置这些颜色,我创建了一个定义背景和文本颜色的主题,并将其应用到主layoutfile白色背景和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> 

我连接后,背景变成白色,但文本颜色保持白色。我做错了什么?为什么我的文字颜色不像我期望的那样黑?

+0

检查在java代码中添加的'setTextColor' –

回答

0

它在清单的应用程序标记中设置我的主题后工作。

相关问题