How to use the new DayNight Theme?

五迷三道 提交于 2019-11-29 06:57:05

问题


Starting to get my hands into that new update to the Google Support Library and I want to implement the Theme.AppCompat.DayNight into my app.
The problem I am having is that it seems no one explained how to customize it. So If I want to have a different colorAccent for day and a different one for night, how do I do that? Are you supposed to specify different dark and light themes to base off of? Thanks in advance!


回答1:


You can use the night resource qualifier folder.
In this way you can define colors and the other resources for the night and for the day.

Qualifiers:
night: Night time
notnight: Day time

Example:

  <style name="AppTheme" parent="Theme.AppCompat.DayNight">
      <item name="colorPrimary">@color/primary</item>
   </style>

In values-night and values-notnight folders define your color:

<color name="primary">XXXX</color>

Pay attention to the official post:

Please consider using the standard colors or taking advantage of the tinting support in AppCompat to make supporting this mode much easier.



来源:https://stackoverflow.com/questions/35629664/how-to-use-the-new-daynight-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!