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

Alperen

02/28/2024, 12:14 PM
Is it possible to use webView in compose without using AndroidView?
🚫 3
In compose, I want to completely eliminate view classes. I couldn't find a library in Compose that corresponds to WebView. My aim is to completely rid of AndroidView. Is there a solution for this? From what I've researched, Compose doesn't currently support this.
s

Sergey Y.

02/28/2024, 12:44 PM
And probably will not. There is no benefit rewriting WebView to Compose. WebView is a complex component that allows to display web pages inside app, using the native browser engine. It has many features and settings that are not easily compatible with the declarative and reactive paradigm of Compose. For example, load URLs, execute JavaScript, and interact with the web content. Trying to create something like WebView just for Compose would be extremely difficult and not very practical. It would mean making a whole new web browser engine just for Compose, which would be a huge task and not worth the effort.
thank you frog 2
j

Joel Denke

02/28/2024, 2:41 PM
Accompanist had webview, but they used AndroidView under the hood. And in Compose, under the hood everything ends up in Zygote and some kind of View before COmpose layer in Android. What I would focus on instead, how to get rid of webviews, thats the main problem I think. Also WebView was complex in old Android views in the past as well. Interesting here with Compose multiplatform can run Compose in web instead, like wasm or such.
thank you frog 1
s

Sergey Y.

02/28/2024, 2:44 PM
Getting rid of WebViews is always a good solution, but it's not always possible. Sometimes, they are just required.
j

Joel Denke

02/28/2024, 2:44 PM
Its always possible, but not always suitable for everyone in terms of time and money 😛
5 Views