Android AppCompat工具栏';s colorControlNormal正在缓存
我正在将我们先前存在的操作栏迁移到Android AppCompat工具栏';s colorControlNormal正在缓存,android,android-layout,android-appcompat,Android,Android Layout,Android Appcompat,我正在将我们先前存在的操作栏迁移到工具栏,我遇到了一个小问题。通常我想要一个带有标准白背箭头的导航图标。但是,在某些情况下,我希望将该箭头更改为灰色。为了实现这一点,我做了以下工作 <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" androi
工具栏
,我遇到了一个小问题。通常我想要一个带有标准白背箭头的导航图标。但是,在某些情况下,我希望将该箭头更改为灰色。为了实现这一点,我做了以下工作
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?actionBarSize"
android:background="?titlebarBackground"
style="?actionBarStyle"
app:navigationIcon="@drawable/action_bar_up_arrow"
app:theme="?toolbarTheme"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
这一功能最初运行完美,我的向上箭头变为灰色。但是,当我返回时,该灰色仍然会保留在后堆栈上所有活动的向上箭头中。如果我打开一个新的活动
,箭头将变为白色,但以前的任何活动的箭头仍设置为灰色
我的问题有两个:
drawable.mutate()
这确实应该在图书馆解决编辑:
对于脏补丁,请在onResume()中执行此操作
更多信息:
还有一个小小的补充:为了使用标准图标(R.drawable.abc\u ic\u ab\u back\u mtrl\u am\u alpha),我必须使用
onRestart
中的TintManager.getDrawable()更新图标的色调。考虑到TintManager在内部软件包中,我不是一个超级粉丝;“有什么办法吗?”乔纳森说。看起来它已修复,但尚未发布。
<style name="ThemeOverlay.AppCompat.Dark.ActionBar.GrayControls">
<item name="colorControlNormal">@color/gray</item>
</style>
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);