Hey guys. I’m having trouble with my UX when I try...
# compose
m
Hey guys. I’m having trouble with my UX when I try to display web content (AndroidView + WebView) in a List of other items (e.g. ads). Whenever the user scrolls “normal” through the content, the AndroidView is getting recomposed and the height is adjusted some milliseconds after it is already in the visible area. This leads to confusing list jumps. Has anybody of you some advices how I can improve the user experience?
Here is some code I’m using: A store class to hold already created and loaded webViews:
Copy code
class WebViewStore(){
    private val map = mutableMapOf<String, WebView>()

    fun getReusableWebView(key: String, create: ((context: Context) -> WebView)) {
      // if already created return WebView from map 
      // otherwise call create and store WebView in Map
   }
}
The composable I am using in my lists to display web content:
Copy code
@Composable
fun WebViewElement(key: String, modifier: Modifier = Modifier) {
    val webViewStore = remember { getKoin().get<WebViewStore>() } // get via DI
    val webView = webViewStore.getReusableWebView(key) { context ->
        createMyCustomWebViewImpl(context) // returns a custom implementation of a WebView
    }

    AndroidView(
        factory = { webView },
        modifier = modifier
    )
}
If you need more information, just let me know ✌️