[英]Toolbar style doesn't work
I'm trying to make a light-blue toolbar with white text color: 我正在尝试制作带有白色文本颜色的浅蓝色工具栏:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
style="@style/ToolbarStyle"/>
and in my styles.xml: 在我的styles.xml中:
<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">?attr/colorPrimary</item>
</style>
But there's one problem, the text color is black instead of white 但是有一个问题,文字颜色是黑色而不是白色
Note: Using android:theme
or app:theme
instead of style
will fix the problem, but I still wanna know, why doesn't style
work? 注意:使用android:theme
或app:theme
代替style
将解决此问题,但我仍然想知道,为什么style
不起作用?
I think I understand the problem now, 我想我现在明白了这个问题,
style
is used to style a view without its children views. style
用于为没有子视图的视图设置样式。 android:theme
and app:theme
are used to style the view and its children. android:theme
和app:theme
用于为视图及其子元素设置样式。
So when it comes to styling the toolbar, you will probably want to style it and its children views so the activity label will be styled as well. 因此,在设计工具栏样式时,您可能需要对工具栏及其子视图进行样式设置,以便对活动标签也进行样式设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.