admin管理员组文章数量:1379395
I am experiencing an issue in my Android app related to using WebView in a fragment while forcing a theme mode opposite to the system's current mode. When the system is in dark mode, I force light mode in my app, and after opening a WebView, the UI components mix between light and dark modes when the WebView is closed. Specifically, I am using setWebViewClient to load a URL, and I've tried controlling WebView settings with forceDark = WebSettings.FORCE_DARK_OFF, but the problem persists.
Steps to Reproduce: 1- The system is in dark mode. 2- I force light mode using the app (via AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)). 3- Open a WebView (with a custom URL) inside a fragment. 4- After the WebView is closed, the app UI components have mixed resources—some appear in dark mode and others in light mode.
What I’ve Tried: 1- Using forceDark = WebSettings.FORCE_DARK_OFF in WebView settings. 2- Calling invalidate() on the decorView. 3= Calling recreate() on the activity, but that resets the state of the app, which I don’t want. 4- Forcing light mode using AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO).
Is there a way to force the UI to stay in light mode (or the chosen mode) after interacting with WebView, without causing mixed resources? What is the best approach to ensure the app doesn’t reset its state while handling theme changes correctly?
本文标签:
版权声明:本文标题:Android WebView Theme Issue: Forced Light or Dark Mode lead Mixed UI Components After WebView Closure - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744411836a2604989.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论