Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

android - What is the difference between colorPrimary and colorPrimaryDark in themes

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.

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>

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>

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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • colorPrimary – The color of the app bar.
  • colorPrimaryDark – The color of the status bar and contextual app bars; this is normally a dark version of colorPrimary.
  • colorAccent – The color of UI controls such as check boxes, radio buttons, and edit text boxes.
  • windowBackground – The color of the screen background.
  • textColorPrimary – The color of UI text in the app bar.
  • statusBarColor – The color of the status bar.
  • navigationBarColor – The color of the navigation bar.

you can use following link to setup your style.

https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...