https://kotlinlang.org logo
#compose
Title
# compose
a

allan.conda

05/20/2022, 1:46 PM
What’s the correct way to update an AndroidView when the Theme/Configuration changes? The view doesn’t update when changing Light/Dark theme
c

Chris Sinco [G]

05/20/2022, 4:22 PM
Have you setup your themes for Views to handle dark theme? Theming for Views is handled differently and separately than Compose
👀 1
m

manju reddy

05/20/2022, 4:58 PM
If you have UIThemes setup, Compose will recompose the UI when Theme changes happen. You can differ the UI based on isSystemInDarkMode or your custom theme based on changes set in ui themes, typography and color.
There is a codelab sample for same
a

allan.conda

05/20/2022, 5:03 PM
@/Chris you mean setting a night and day resource right? Basically theming works initially, but doesn’t update anymore when changing theme at runtime. Hmm, one thing is that I disabled all
configChange
as recommended in some thread here, so it doesn’t re-create the Activity. Now usually that means handling stuff in
onConfigurationChange
myself, and Compose handles that gracefully, but it doesn’t work for AndroidViews and I’m not sure how to.
If there’s some way for AndroidView to re-inflate somehow…
c

Chris Sinco [G]

05/20/2022, 6:30 PM
cc @Nick Rout
🙏 1
5 Views