Can Android's WebView automatically resize huge images?

前端 未结 8 1835
心在旅途
心在旅途 2020-11-28 05:41

In some web browsers, huge images are automatically resized to fit the screen.

Is it possible to do the same in an Android WebView?

The web page just contain

8条回答
  •  渐次进展
    2020-11-28 06:17

    Yes, it's possible. You can try setting the WebView Layout using the code below. It resizes all Images (Greater than the Device Screen Width) to the Screen Width. This works for both Orientations (Portrait and Landscape)

    webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    

    You can add extra margins/padding later to get the spacing right.

提交回复
热议问题