android Wear 应用上的白色背景和黑色文本颜色
white background and black text color on android wear app
在我的 android Wear 应用程序中,我需要将默认的黑色背景更改为白色,并将文本颜色更改为黑色。为了不在每次创建新布局文件时都设置这些颜色,我创建了一个主题来定义背景和文本颜色并将其应用于主布局文件
布局文件:
<?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>
粘贴后,背景变成了白色,但文字颜色仍然是白色。我做错了什么?为什么我的文本颜色不是我期望的黑色?
在我将主题设置在清单的应用程序标签中后它起作用了。
在我的 android Wear 应用程序中,我需要将默认的黑色背景更改为白色,并将文本颜色更改为黑色。为了不在每次创建新布局文件时都设置这些颜色,我创建了一个主题来定义背景和文本颜色并将其应用于主布局文件
布局文件:
<?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>
粘贴后,背景变成了白色,但文字颜色仍然是白色。我做错了什么?为什么我的文本颜色不是我期望的黑色?
在我将主题设置在清单的应用程序标签中后它起作用了。