abhilash kaveriappa
abhilash kaveriappa

Reputation: 169

How to Zoom Only Image in Android Webview Onclick on Image?

In my app only page gets zoom. How to Zoom any images in android webview on tapping image. Please help me with an example source code.

Upvotes: 2

Views: 390

Answers (1)

abhilash kaveriappa
abhilash kaveriappa

Reputation: 169

BINGO!!! I found a temporary solution to this problem. Injected custom CSS to android Webview and I was able to scale image.

 contentText = new StringBuilder().append(AppConstant.CSS_PROPERTIES).append(contentText).toString();
                    webEngine.loadHtml(contentText);

And I customized CSS properties in java class file. When I tap on the image it gets scaled by 150%

 public static final String CSS_PROPERTIES = "<style>" +
            "img:hover{transform: scale(1.5) rotate(270deg); transition:0.5s ease;margin-left:auto;margin-right:auto;}"
            + "</style>" ;

Any Suggestion please comment.

Upvotes: 1

Related Questions