AndroidX BottomAppBar导航图标颜色 [英] AndroidX BottomAppBar navigation icon color
问题描述
我在这样的布局中定义了一个底部栏:
I've defined a bottom bar in a layout like that:
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:navigationIcon="@drawable/ic_menu_black_24dp" />
导航图标是从新的矢量可绘制"向导生成的常规图标.有没有办法对它应用色彩?
The navigation icon is a generic icon generated from the "new vector drawable" wizard. Is there a way to apply a tint to it?
底部栏不是活动操作栏.
The bottom bar is not the activity action bar.
到目前为止我尝试过的事情:
What I've tried so far:
- 应用了具有覆盖的
textColorPrimary
颜色 的主题 - 应用具有覆盖的
controlColorNormal
颜色 的主题
- applied a theme with an overridden
textColorPrimary
color - applied a theme with an overridden
controlColorNormal
color
如果有一种解决方案也适用于通过从XML加载菜单(使用 inflateMenu()
或 replaceMenu()
)提供的图标,那将是完美的./p>
If there's a solution that also works on icons supplied by loading a menu from XML (using inflateMenu()
or replaceMenu()
), that would be perfect.
推荐答案
导航图标的颜色基于 colorControlNormal
属性.
您可以使用以下方法覆盖它:
The navigation icon color is bases on colorControlNormal
attribute.
You can override it using:
<com.google.android.material.bottomappbar.BottomAppBar
android:theme="@style/ThemeOverlay.BottomAppBar"
具有:
<style name="ThemeOverlay.BottomAppBar">
<item name="colorControlNormal">@color/....</item>
</style>
这篇关于AndroidX BottomAppBar导航图标颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!