2016-09-05 31 views
3

我正在使用styles.xml如下主題:Android操作欄,文本自定義顏色

<style name="AppTheme" parent="Theme.AppCompat.Light"> 
    <item name="colorPrimary">@color/md_blue_700</item> 
    <item name="android:colorAccent">@color/md_blue_900</item> 
    <item name="android:colorPrimaryDark">@color/md_blue_900</item> 
    <item name="android:windowBackground">@color/md_white_1000</item> 
    <item name="android:colorControlNormal">@color/md_blue_700</item> 
    <item name="android:colorControlActivated">@color/md_blue_700</item> 
    <item name="android:colorControlHighlight">@color/md_blue_700</item> 
    <item name="android:textColorPrimary">@color/md_white_1000</item> 
</style> 

這我聲明由於Android:在AndroidManifest.xml主題:

<activity 
     android:name=".LoginActivity" 
     android:theme="@style/AppTheme" 
     android:label="@string/activity_login_actionbar" /> 

的問題在下圖中以紅色突出顯示。

因爲我設置

<item name="android:textColorPrimary">@color/md_white_1000</item> 

白色進度條的文字也顯得白,是無形的。如果我將其更改爲灰色,則操作欄中的文本也會變成我不想要的灰色。

我已經嘗試了諸如爲進度對話框創建單獨主題之類的東西,但是當我這樣做時,我失去了對話框的圓角等。

這是創建微調我的Java代碼:

progressDialog = new ProgressDialog(this); 
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
progressDialog.setTitle("Attempting Sign In"); 
progressDialog.setMessage("Please wait..."); 
progressDialog.setCancelable(false); 

我應該如何去解決這個問題呢?

所有答案讚賞!

enter image description here

+0

什麼一個有趣和平衡的問題 –

回答

2

您可以使用Theme.AppCompat.Light.DarkActionBar和你的主題風格刪除<item name="android:textColorPrimary">@color/md_white_1000</item>,那麼標題會變成白色。你可以檢查比較Light and Dark themes here

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/md_blue_700</item> 
    <item name="android:colorAccent">@color/md_blue_900</item> 
    <item name="android:colorPrimaryDark">@color/md_blue_900</item> 
    <item name="android:windowBackground">@color/md_white_1000</item> 
    <item name="android:colorControlNormal">@color/md_blue_700</item> 
    <item name="android:colorControlActivated">@color/md_blue_700</item> 
    <item name="android:colorControlHighlight">@color/md_blue_700</item> 
</style>