I need to use WebView in place of Text
composable (to display complex text and maths). Size of the WebView
will depend on amount of content(text). But currently it only works when a fixed size modifier is applied. Without fixed size; WebView stutters while loading and many times it wont even show up.
I am loading content using loadWithBaseUrl()
method.
I have tried using WebView
composable from Accompanist library; Also tried my custom implementation; but it still wont work.
// implementation 'com.google.accompanist:accompanist-webview:0.24.3-alpha'
LazyColumn(){
item {
val webViewState = rememberWebViewStateWithHTMLData(data = FakeData.HTML_DOC)
Surface(
modifier = Modifier.padding(8.dp, 8.dp).height(IntrinsicSize.Min)
) {
WebView(
state = webViewState,
modifier = Modifier
// .size(400.dp, 200.dp) // When fixed size applied problem disappears
)
}
}
}
Use custom
AccompanistWebViewClient
, overrideonPageFinished
, you can get webPage height byevaluateJavascript
.