android自定义工具栏如何设置后退按钮为白色? [英] android custom toolbar how to set back button be white?
本文介绍了android自定义工具栏如何设置后退按钮为白色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
style/AppTheme:
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/ActivityCustomToolbarTheme:
<style name="ActivityCustomToolbarTheme" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
工具栏:
<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"/>
我将app:theme
设置为此,但是它始终是黑色.如果设置@style/ThemeOverlay.AppCompat.Dark
,则它是灰色.
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?
推荐答案
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);
}
这篇关于android自定义工具栏如何设置后退按钮为白色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文