主题中的 colorPrimary 和 colorPrimaryDark 有什么区别 [英] What is the difference between colorPrimary and colorPrimaryDark in themes
问题描述
我正在尝试了解该主题在 android 中的工作原理.我不知道为什么 colorPrimaryDark 对我不起作用,或者我做错了.
I'm trying to understand how the theme works in android. I don't know why colorPrimaryDark won't work with me or maybe i'm doing it wrong.
我尝试了这个设置,但由于 colorPrimary,我的操作栏变成了红色:
I tried this set and my action bar turns red because of colorPrimary:
<style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#FF0000</item>
<item name="colorPrimaryDark">#0000FF</item>
<item name="colorAccent">#00FF00</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
我试图删除 colorPrimary 并且它变成黑色(我认为它会因为 colorPrimaryDark 而使用蓝色:
I tried to remove the colorPrimary and it turns black (which I thought it will use blue because of colorPrimaryDark:
<style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">#0000FF</item>
<item name="colorAccent">#00FF00</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
我尝试删除 colorPrimaryDark 并留下 colorPrimary 并且它再次变为红色:
I tried to remove the colorPrimaryDark and left the colorPrimary and it turns red again:
<style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#FF0000</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
我不知道我是否以错误的方式使用它,或者它根本没有真正改变.谁能告诉我它们之间的区别?
I don't know if i'm using it in wrong way or it's not really changing at all. Can anyone tell me the difference among them?
我还尝试了 actionMenuTextColor 来更改 actionBar 中的文本颜色,但没有任何反应.我找到了使用 parent="Theme.AppCompat.Light.DarkActionBar" 而不是 parent="Theme.AppCompat.Light" 单独的解决方案.但当然它只会变成白色.如果有任何办法,我仍在尝试将其改成不同的颜色.
I also tried actionMenuTextColor to change the text color in actionBar but nothing happened. I found out the solution using parent="Theme.AppCompat.Light.DarkActionBar" instead of parent="Theme.AppCompat.Light" alone. But of course it will only turn into white. I'm still trying to make it in different color if there is any way.
推荐答案
- colorPrimary – 应用栏的颜色.
- colorPrimaryDark – 状态栏和上下文应用程序的颜色酒吧;这通常是 colorPrimary 的深色版本.
- colorAccent – 复选框、单选等 UI 控件的颜色按钮和编辑文本框.
- windowBackground – 屏幕背景的颜色.
- textColorPrimary – 应用栏中 UI 文本的颜色.
- statusBarColor – 状态栏的颜色.
- navigationBarColor – 导航栏的颜色.
您可以使用以下链接来设置您的风格.
you can use following link to setup your style.
https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/
这篇关于主题中的 colorPrimary 和 colorPrimaryDark 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!