How to use the new DayNight Theme?

前端 未结 1 1141
忘了有多久
忘了有多久 2020-12-29 07:59

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

1条回答
  •  北海茫月
    2020-12-29 08:34

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

    Qualifiers:
    night: Night time
    notnight: Day time

    In order to support the dark theme with a Material Components Theme use:

    
    

    With an AppCompat theme:

      
    

    Then define in your app theme the references color resources, and override the value in the values-night directory if needed:

    Example: res\values\colors.xml:

       .....
    

    In res\values-night\colors.xml folders define the same color:

       .....
    

    0 讨论(0)
提交回复
热议问题