gpt4 book ai didi

Android Lollipop 工具栏反转颜色

转载 作者:太空狗 更新时间:2023-10-29 16:16:12 25 4
gpt4 key购买 nike

我正在为 Android L 的工具栏-ActionBar 使用 Android L v21 支持库。我希望工具栏中的项目为白色。即导航后退按钮、操作按钮、溢出操作。如果我使用深色版本作为应用程序主题 (Theme.AppCompat.NoActionBar),则所有工具栏项目都显示为白色。但是当我为应用程序使用浅色版本 (Theme.AppCompat.Light.NoActionBar) 时,所有工具栏项目都显示为深色。我想使用浅色主题,并想让工具栏显示为白色。

我已经使用 activity.setTitleTextColor() 更改了标题的文本颜色,但不确定如何更改其余部分的颜色。

Android L Toolbar

解决方案:

感谢@ianhanniballake

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>

最佳答案

根据 AppCompat v21 blog post在样式下:

Styling of Toolbar is done differently to the standard action bar, and is set directly onto the view.

例如:

<android.support.v7.widget.Toolbar  
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

注意 app:theme将操作栏设置为使用浅色文本/样式的属性(ThemeOverlay.AppCompat.Dark.ActionBar 相反)。

关于Android Lollipop 工具栏反转颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26645559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com