大佬教程收集整理的这篇文章主要介绍了Android 在深色模式下更改工具栏背景颜色,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
哪里可以在深色模式下更改工具栏的背景颜色?我没有自定义工具栏。我想在主题中更改它。我改变了 灯光模式:colorPriMaryVariant 这改变了我工具栏的背景,但是当我在夜间 xml 文件中做同样的事情时,应用程序没有反应。为什么?
我的 xml 代码如下所示:
<resources xmlns:tools="http://scheR_410_11845@as.androID.com/tools">
<!-- Base application theme. -->
<style name="theme.FastDraw" parent="theme.MaterialComponents.DayNight.DarkActionbar">
<!-- PriMary brand color. -->
<item name="colorPriMary">@color/iconlightGrey</item>
<item name="colorPriMaryVariant">@color/iconDarkGrey</item>
<item name="colorOnPriMary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="androID:statusbarcolor" tools:targetAPI="l">?attr/colorPriMaryVariant</item>
<!-- Customize your theme here. -->
<item name="actionbartheme">@style/ToolbarStyle</item>
<item name="androID:textcolor">@color/black</item>
<item name="androID:textcolorPriMary">@color/black</item>
</style>
<style name="ToolbarStyle" parent="themeOverlay.MaterialComponents.Dark.Actionbar">
<item name="androID:textcolorPriMary">@color/white</item>
</style>
</resources>
我相信,既然您已经为工具栏使用了自定义样式,那么您应该更改它并在那里分配。
<style name="ToolBarStyle" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar">
<item name="android:textColorPriMary">@color/white</item>
<item name="colorOnPriMary">@color/....</item>
</style>
以上是大佬教程为你收集整理的Android 在深色模式下更改工具栏背景颜色全部内容,希望文章能够帮你解决Android 在深色模式下更改工具栏背景颜色所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。