问题
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 timenotnight
: 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