我想用透明的应用程序栏和图像背景将我的应用程序名称颜色设置为灰色。然而,由于某些原因,应用程序名称的颜色保持为白色。下面是我的代码。有什么建议吗?提前谢谢你!
1. Themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.DailyBread" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</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. -->
</style>
<style name="AppTheme.ActionBar.Transparent" parent="Theme.DailyBread">
<item name="titleTextColor">@color/gray_dark</item>
<item name="android:textColorPrimary">@color/gray_dark</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimary">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
2. color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray_dark">#696665</color>
<color name="gary_light">#bdbab9</color>
</resources>
1条答案
按热度按时间5hcedyr01#
创建您的
toolbar.xml
背景为AppBarLayout
是@null
:附言:你也可以使用
android:background="@android:color/transparent"
而不是@null
.结果: