I would like to convert a WebView into a @Composable. I am looking for something similar to SwiftUI's UIRepresentable.
I saw there was a @GenerateView annotation but,
1. that did the opposite of what I wanted(converted a @Composable into xml)
2. @GenerateView seems to have been taken away(I am using Dev05).
I think that feature is not supported yet. But you can interop traditional views with jetpack compose.
@Composable
fun Browser(list: List<String>) {
Column(modifier = Modifier.fillMaxSize()) { item ->
AndroidView(
modifier = Modifier.fillParentMaxWidth().height(50.dp),
viewBlock = { context ->
WebView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
}
})
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With