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>
我連接後,背景變成白色,但文本顏色保持白色。我做錯了什麼?爲什麼我的文字顏色不像我期望的那樣黑?
檢查在java代碼中添加的'setTextColor' –