AppCompat V21深色工具栏风格 [英] AppCompat v21 Dark ToolBar style
问题描述
我想我的工具栏,作为一个动作条,我希望它看起来像一个光的主题与黑暗的操作栏。我似乎无法找到合适的组合,以做到这一点。
I want my ToolBar to serve as an ActionBar and I want it to look like a light theme with a dark action bar. I can't seem to find the right combination to do it.
这是我在styles.xml
This is what I have in styles.xml
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/my_awesome_color</item>
<item name="android:textColorPrimary">@color/my_awesome_text_color</item>
<item name="colorPrimaryDark">@color/my_awesome_darker_color</item>
<item name="colorAccent">@color/accent</item>
</style>
和我的工具栏
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
目前我得到这个
我要的是,该菜单项是白色以及
What I want is that the menu items be white as well
有一种优雅的解决方案,或者我要选择适合的工具栏的项目每一个自定义样式?这似乎应该有。
Is there an elegant solution or do I have to choose a custom style for each one of the toolbar's items? It seems there should be.
推荐答案
您可以使用工具栏上的以下主题让它显得暗。第一部分应用:主题
主题工具栏上的文本的颜色要轻等等。该应用程序:popupTheme
是造型溢出菜单指示要轻
You can use the following theme on your Toolbar to get it to appear "dark". The first portion app:theme
themes the color of the text on Toolbar to be light among other things. The app:popupTheme
is for styling the overflow menu indicator to be light.
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="@dimen/triple_height_toolbar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
这篇关于AppCompat V21深色工具栏风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!