2016-05-28 55 views
0

我正在開發使用Android Studio的Android應用程序。坦率地說,我不擅長Android開發。我在設置主題到我的應用程序時遇到問題。我將樣式資源文件中的整個應用程序的文本顏色設置爲主題。但它不起作用。請參閱下面的我的場景。將文字顏色設置爲Android中的主題無效

這是我的顏色資源文件

enter image description here

正如你所看到的,我都設置文本顏色爲紅色。

這是我的風格的資源文件的主題

enter image description here

我設置了主題爲這樣

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

但當清單文件中的應用我運行的文字顏色不變。你可以在下面看到。

enter image description here

所以請爲什麼它不工作?我該如何修復我的代碼?我怎樣才能爲整個應用程序設置文本顏色?

回答

0

您的活動主題正確設置爲AppTheme.NoActionBar。但是,該主題在styles.xml中沒有父項,這意味着TextView顏色不會從默認值更改。你可以通過像這樣繼承AppTheme來解決這個問題:

<style name="AppTheme.NoActionBar" parent="AppTheme"> 
相關問題