【问题标题】:How to Zoom Only Image in Android Webview Onclick on Image?如何在 Android Webview Onclick 上仅缩放图像?
【发布时间】:2020-06-29 06:52:33
【问题描述】:

在我的应用中,只有页面可以缩放。 如何在点击图像时缩放 android webview 中的任何图像。 请帮助我提供示例源代码。

【问题讨论】:

    标签: android android-studio webview android-webview androidx


    【解决方案1】:

    宾果游戏!!!我找到了这个问题的临时解决方案。 将自定义 CSS 注入到 android Webview 中,我能够缩放图像。

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

    我在 java 类文件中自定义了 CSS 属性。当我点击图像时,它会缩放 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>" ;
    

    任何建议请评论。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 2012-05-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多