1

ツールバーの私のハンバーガー/バックローの色をcolorPrimaryDarkからwhiteに変更したいと思います。ハンバーガー/バックローツールバーの色を変更します。Android

私style.xmlファイルで

私は2つのテーマがあります。

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorPrimary</item> 
    <item name="colorButtonNormal">@color/white</item> 
    <item name="android:windowTranslucentStatus">true</item> 
</style> 


<!-- Toolbar theme. --> 
<style name="toolbar" parent="AppTheme"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/white</item> 
    <item name="colorControlNormal">@color/white</item> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:textColorPrimary">@color/white</item> 
    <item name="android:textColor">@color/black</item> 
    <item name="android:textColorSecondary">@android:color/white</item> 
</style> 

を、これは私のツールバーです:

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:fitsSystemWindows="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/colorPrimary" 
    android:elevation="4dp" 
    android:theme="@style/toolbar"> 
</android.support.v7.widget.Toolbar> 

が、私はいくつかの方法から<item name="android:textColorSecondary">@android:color/white</item>を移動している作品だけで試してみましたツールバーのテーマを基にアプリケーションのテーマを設定します。

基本テーマでtextColorSecondaryを白に設定すると、他のコンポーネントの色も変わるので、それは私にとってはうまくありません。 ツールバーにのみ設定したいです。しかし、それは私が<item name="android:textColorSecondary">@android:color/white</item>を持っていると"android:theme="@style/toolbar"

enter image description here

enter image description here

を使用してtoolbar.xmlに私のツールバーのスタイルを設定していても奇妙なことは、他のテーマの色が正しく適用されていることである動作しません。

どこが間違っていますか?

+0

[これ](http://stackoverflow.com/questions/31870132/how-to-change-color-of-hamburger-icon-in-material-design-navigation-drawer)を試しましたか? – azizbekian

+0

はい、ハンバーガーアイコンの色だけが変更されますが、その理由は何ですか? – BitRulez

答えて

1

仕事は周り:これで

toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material); 

と変更ハンバーガー色:

私はこれでデフォルトの矢印のアイコンを設定し

(しかし、私は、それはエレガントな解決策はないと思います)

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorPrimary</item> 
     <item name="colorButtonNormal">@color/white</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/white</item> 
</style> 
関連する問題