Search code examples
androidkotlinandroid-webview

How to setSupportZoom in Kotlin


I know that there is a way to support zoom in java: webview.getSettings().setSupportZoom(true). But I've been searching for a while for this in Kotlin. And yes, I have tried using the converter try.kotlinlang.org but It gives me the same piece of code. Does somebody know how to support zoom in Kotlin?


Solution

  • Why not simply:

    var webView: WebView = view.findViewById(R.id.webview)
    webView.settings.setSupportZoom(true)
    

    Update

    As per your comments you would want to do this as well:

    webView.settings.builtInZoomControls = true // enable pinch to zoom and zoom controls
    webView.settings.displayZoomControls = false // hides the zoom controls so you can just pinch to zoom