How to make circular reveal effect when theme changed? (Like in Telegram or VK)
Asked Answered
H

1

8

I am using DayNight theme in my application. And I have a button that changes the theme. In VK and Telegram app there is a beautiful reveal animation that changes the theme without restarting activity or something like that.

I have tried to make that with reveal animation implementation in different ways, but it doesn't work or working bad in some cases with AppCompatDelegate.setDefaultNightMode(...). All examples with that reveal animation are for ActivityA -> ActivityB, but I just need to update theme without starting any activity.

And one more thing: AppCompatDelegate.setDefaultNightMode recreates my activity, so do I need a custom theme changing implementation?

And main question: how to create that animation with theme changing?

Examples:

Telegram (From Dark to Light)

Telegram (From Light to Dark)

VK (From Light to Dark)

VK (From Dark to Light)

Hippolytus answered 18/1, 2020 at 19:38 Comment(0)
C
12

since telegram is an open source app you can find the code -> line 3154: github. it seems that it converts layout into bitmap and use it with an existing imageView to animate circular reveal

Crispas answered 18/1, 2020 at 20:23 Comment(4)
what will be the value of args[2] in code?Roadbed
@basaveshwarlamture perhaps the coordinates of theme toggle buttonEaglet
the question is how telegram shows an ImageView on entire screen even status bar?Facing
args[2] found in DrawerProfileCell.java - method: switchTheme()Consensual

© 2022 - 2024 — McMap. All rights reserved.