android webview zoom /pinch to zoom android studio

Hello android developer, in this article we will learn how to enable pinch to zoom on webview. using this source code you can enable WebView zoom.

please follow the code given below to enable pinch to zoom on webview.

  • First Create a new project in Android Studio
  • File ⇒ New Android ⇒ Application Project
  • Then Open src -> package -> MainActivity.java and then add following code :

JAVA (MainActivity.java)

  •  Now Open res -> layout -> activity_main.xml and then add following code :

XML (activity_main.xml)

Output:

Finally, run this project.

This is how the application looks like.

pinch to zoom on webview pinch to zoom on webview pinch to zoom on webview

 

Leave a Reply

Your email address will not be published.