2017-08-09 22 views
0

工具欄文本和漢堡包圖標爲黑色,我需要白色。 我試過this,thisthis解決方案,但沒有任何工作。
源代碼鏈接:https://github.com/vaibhavsingh97/Solucion/tree/master/Android%20Basic%20Nanodegree/Project%206/TourGuide如何設置工具欄文本和漢堡包圖標爲白色?

Styles.xml

<!-- 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 name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> 
     <item name="android:textColorPrimary">@color/white</item> 
     <item name="android:textColorSecondary">@color/white</item> 
    </style> 

</resources> 

app_bar_main.xml

<android.support.design.widget.AppBarLayout 
     style="@style/AppTheme.AppBarOverlay" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_home" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="16dp" 
     android:src="@drawable/ic_play"/> 

</android.support.design.widget.CoordinatorLayout> 

Android Studio中:用於構建3.0金絲雀9
SDK:26

enter image description here

+0

如果您在應用程序主題中設置文本顏色主文本和文本顏色輔助文件,會發生什麼情況? –

回答

2

內的活動,您可以使用

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    toolbar.setTitleTextColor(getResources().getColor(R.color.white)); 

如果你喜歡選擇這兩個標題顏色& XML後退箭頭白剛style.xml添加這種風格。

<style name="ToolBarStyle" parent="Theme.AppCompat"> 
    <item name="android:textColorPrimary">@android:color/white</item> 
    <item name="android:textColorSecondary">@android:color/white</item> 
    <item name="actionMenuTextColor">@android:color/white</item> 
</style> 

和工具欄的樣子:

<android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     app:theme="@style/ToolBarStyle" 
     android:layout_height="?attr/actionBarSize" 
    /> 

UPDATE

試試這個

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base"> 

</style> 

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> 
</style> 

<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle"> 
    <item name="spinBars">true</item> 
    <item name="color">@android:color/black</item> 
</style> 

因此,檢查<item name="color">@android:color/black</item>線。在這裏改變你想要的顏色。

+0

問題仍然存在,只有工具欄文字顏色變爲白色 –

+0

請參閱update =)!!! –

+0

謝謝!它的工作:) –

相關問題