2016-05-29 81 views
0

我想更改我的動作欄中的文字顏色。我嘗試了很多東西,但無法改變它。在圖片我想改變字組白色動作欄文字顏色

這是我的styles.xml文件:

<resources> 
    <!-- Base application theme. --> 
    <style name="MyCustomTheme" parent="android:style/Theme.Holo.Light"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="android:actionBarStyle">@style/MyCustomTheme.MyActionBar</item> 
     <item name="android:textViewStyle">@style/MyTextViewStyle</item> 
     <item name="android:buttonStyle">@style/MyButtonStyle</item> 
     <item name="android:editTextStyle">@style/MyEditTextStyle</item> 
    </style> 

    <style name="MyCustomTheme.MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">@color/colorPrimary</item> 
     <item name="android:textSize">@dimen/edit_text_text_size</item> 
    </style> 

    <style name="MyTextViewStyle" parent="android:Widget.TextView"> 
     <item name="android:fontFamily">@string/app_font</item> 
     <item name="android:textSize">@dimen/edit_text_text_size</item> 
    </style> 

    <style name="MyEditTextStyle" parent="android:Widget.EditText"> 
     <item name="android:fontFamily">@string/app_font</item> 
     <item name="android:textSize">@dimen/edit_text_text_size</item> 
    </style> 

    <style name="MyButtonStyle" parent="android:Widget.Holo.Button"> 
     <item name="android:fontFamily">@string/app_font</item> 
     <item name="android:textSize">@dimen/edit_text_text_size</item> 
    </style> 
</resources> 

這是我的動作條: http://pichoster.net/lPd

+0

你想要一個白色的顏色? – slanecek

+0

@Alex Tech使用此代碼...

回答

0

我認爲這應該工作。

int titleId = getResources().getIdentifier("action_bar_title", "id", "android"); 

現在你可以使用IDTextView

TextView abTitle = (TextView) findViewById(titleId); 
abTitle.setTextColor(colorId); 
+0

http://chat.stackoverflow.com/房間/ 112107/android-smartness – Piyush

+0

明白了嗎???????? – Piyush

+0

讓我們[在聊天中繼續討論](http://chat.stackoverflow.com/rooms/113280/discussion-between-dipali-shah-and-piyush-gupta)。 –