本文介绍了主题中的colorPrimary和colorPrimaryDark有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解主题在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有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 06:17