【发布时间】:2020-07-03 08:26:02
【问题描述】:
我正在集成暗模式,我有折叠工具栏和工具栏,它们包含在 appbarlayout 中, 问题是当我在设置暗模式时尝试将工具栏标题颜色设置为白色时,它在亮模式下不起作用,颜色相应地显示,我几乎尝试了所有方法,但我不知道到底发生了什么,我有 color 和 color night 文件夹,我为两者设置了颜色并将其添加到我的工具栏,但它没有改变任何东西,如果有人能提供帮助,我将不胜感激,谢谢
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".View.MealDetails">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbarlaout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/collapsingtoolbar"
android:fitsSystemWindows="true"
app:contentScrim="@color/toolbarcolor"
app:titleEnabled="true"
app:title="@{details.strMeal}"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="190dp"
app:mealDetailsImg="@{details.strMealThumb}"
android:background="@drawable/noimg"
tools:ignore="ContentDescription" />
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/mealdetailstoolbar"
app:menu="@menu/addfavmenu"
app:navigationIcon="@drawable/arrow_back_black"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
- 这是颜色文件夹
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#000000</color> // changing status bar color
<color name="colorAccent">#000000</color> // changing icons color
<color name="textColorPrimary">#000000</color> // i m not sure if this is correct but i think it is for toolbar text ( i could be wrong )
<color name="ratetextcolor">#000000</color> /// this is to change rate text color
<color name="iconscolor">#000000</color> // this is for icons color
<color name="faviconcolor">#d10d06</color> // i have an icon which i wanted to settle to red in light mode and blue in dark mod
<color name="categoryareacolor">#000000</color> //textviews
<color name="headerColor">#ffffff</color>
</resources>
- 这是夜间文件夹
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#6200EE</color>
<color name="colorAccent">#6200EE</color>
<color name="textColorPrimary">#ffffff</color>
<color name="ratetextcolor">#ffffff</color>
<color name="iconscolor">#3266a8</color>
<color name="faviconcolor">#3266a8</color>
<color name="categoryareacolor">#000000</color>
</resources>
【问题讨论】:
-
您使用的是哪个应用主题?
-
-
你能告诉我
values和values-night文件夹中的colors.xml吗 -
我进行了编辑,谢谢,我不确定我是否做错了什么,textColorPrimary 不是负责更改工具栏标题颜色的吗?
-
那些xml文件中没有
toolbarcolor,它在哪里?
标签: android android-toolbar android-theme android-collapsingtoolbarlayout