2017-06-03 61 views
0

我正在努力設置我的android.widget.Toolbar上的「漢堡包」圖標的顏色,也是我在網上找到的大多數答案適用於support/v7工具欄,但我使用的是android.widget.Toolbar。android.widget.Toolbar主頁按鈕顏色(不支持/ v7/AppCompat工具欄)

這是我的代碼如下所示:

Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); 
     setActionBar(toolbar); 
     ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_closed); 
     drawerLayout.addDrawerListener(drawerToggle); 
     ActionBar actionBar = getActionBar(); 
     actionBar.setDisplayHomeAsUpEnabled(true); 
     actionBar.setHomeButtonEnabled(true); 
     drawerToggle.syncState(); 

我希望能夠風格在我styles.xml文件,這可能嗎?我正在使用材質主題,這是我當前的styles.xml:

<resources> 
    <style 
     name="AppTheme" 
     parent="@android:style/Theme.Material.Light.NoActionBar"> 

     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="android:textColor">@color/textColor</item> 
     <item name="iconColor">@color/iconColor</item> 
    </style> 

    <style 
     name="SplashTheme" 
     parent="AppTheme"> 

     <item name="android:windowBackground">@drawable/splash_screen</item> 
    </style> 
</resources> 

感謝您的幫助。

回答

1

嘗試在styles.xml

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

,然後創建這種風格將它添加到你的應用程序的主題,像這樣:

<item name="drawerArrowStyle">@style/DrawerArrowStyle</item> 
+0

非常感謝你。小問題:混合材質主題和AppCompat主題沒有問題嗎? –

+0

其實AppCompat是支持那些不支持Material Themes的設備的支持庫。所以你可以混合它......他們會工作 –