2016-03-09 125 views
0

您好,我需要更改操作欄的文本顏色方面的幫助欄以下是我的style.xml.I需要將文本顏色更改爲白色,包括設置圖標。如何更改Android中的文本顏色操作欄

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" > 

    </style> 
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 
</resources> 

String.xml源代碼如下。

<resources> 
    <string name="app_name">yebo</string> 

    <string name="navigation_drawer_open">Open navigation drawer</string> 
    <string name="navigation_drawer_close">Close navigation drawer</string> 

    <string name="action_settings">Settings</string> 

</resources> 
+0

試試這個http://stackoverflow.com/questions/5861661/actionbar-text-color – Jas

回答

0

變化。

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 

添加下面那條線:

<item name="actionMenuTextColor">Your Color Here</item> 
    <item name="textColorPrimary">Your Color Here</item> 
</style> 

希望它能幫助。

-1

試試這個:在你的風格

Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); 
toolbar.setTitle(R.string.app_name); 
toolbar.setTitleTextColor(getResources().getColor(R.color.someColor)); 
setSupportActionBar(toolbar); 
+1

我在哪裏可以放置在主類中的代碼 – user3551487

+0

嘗試。 –

1

您可以簡單地把顏色你的字符串是這樣的:

<string name="app_name"><![CDATA[<b><font color=#FFFFFF>yebo</b>]]></string> 
0

試試這個

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MyTheme" parent="@android:style/Theme.Holo.Light"> 
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item> 
    </style> 

    <style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar"> 
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item> 
    </style> 

    <style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> 
    <item name="android:textColor">@color/red</item> 
    </style> 
</resources> 
0

衣被合計/ styles.xml使用colors.xml文件。當你按下「控制」,然後單擊@ color/colorPrimary時,它會顯示colorPrimary的來源。這是colors.xml。在你的colors.xml文件中,你可以編輯它。

Colors.xml

當你點擊離開它的顏色會打開調色板。你可以輕鬆地改變它。 Color palette

0

在.axml中放置一個RelativeLayout來添加操作欄。在這裏添加一個TextView屬性爲android:textColor =「#FFFFFF」。 (#FFFFFF是白色的)。因此:

<RelativeLayout 
    android:id="@+id/titleBarLinearLayoutFrontPage" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="55dp" 
    android:background="#696969"> 
    <TextView 
     android:textColor="#FFFFFF" 
     android:id="@+id/txtActionBarText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="My Action Bar" 
     android:layout_gravity="center" 
     android:clickable="true" 
     android:layout_centerVertical="true" 
     android:textSize="22dp" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="60dp" 
     android:layout_centerHorizontal="true" /> 
</RelativeLayout>