android custom toolbar how to set back button be white?

ぃ、小莉子 提交于 2019-12-14 03:20:04

问题


style/AppTheme:

<style name="AppTheme" 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="android:windowBackground">@color/colorBackground</item>
</style>

style/ActivityCustomToolbarTheme:

<style name="ActivityCustomToolbarTheme" parent="AppTheme">
   <item name="windowActionBar">false</item>
   <item name="windowNoTitle">true</item>
</style>

Toolbar:

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

i set the app:theme to this,but it always is black.if set @style/ThemeOverlay.AppCompat.Dark,it is grey.

other activity that don't custom is ok,but how to set the custom theme?


回答1:


Use this

    protected void showBackButton() {
        mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerToggle.setDrawerIndicatorEnabled(false);
        final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.ic_back); (R.drawable.ic_back==> your own drawable .png)
        mDrawerToggle.setHomeAsUpIndicator(upArrow);
        setSupportActionBar(mToolbar);
    }



回答2:


Try this:

<android.support.v7.widget.Toolbar
     android:id="@+id/toolbar"
     android:layout_width="match_parent"
     android:layout_height="?attr/actionBarSize"
     app:layout_collapseMode="pin"
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

I.e. using @style/ThemeOverlay.AppCompat.Dark.ActionBar (instead of @style/ThemeOverlay.AppCompat.Dark) when setting the toolbar's app:theme.



来源:https://stackoverflow.com/questions/36420991/android-custom-toolbar-how-to-set-back-button-be-white

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!