我正在使用Android Studio开发Android应用。坦率地说,我不擅长Android开发。我在设置主题到我的应用程序时遇到问题。我将样式资源文件中的整个应用程序的文本颜色设置为主题。但它没有用。请参阅下面的方案。
这是我的颜色资源文件
如您所见,我将两种文本颜色都设置为红色。
这是我在样式资源文件中的主题
我在清单文件中设置应用程序的主题,如此
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deltatripagent.deltatripagent" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
但是当我运行文字时颜色没有变化。你可以在下面看到。
那么请问为什么它不起作用?我该如何修复我的代码?如何为整个应用程序设置文本颜色?
答案 0 :(得分:0)
您的活动主题已正确设置为AppTheme.NoActionBar
。但是,该主题在styles.xml中没有父级,这意味着TextView颜色不会从默认值更改。您可以通过继承AppTheme来解决这个问题:
<style name="AppTheme.NoActionBar" parent="AppTheme">