Can Android's WebView automatically resize huge images?

前端 未结 8 1841
心在旅途
心在旅途 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:41

    You can have the browser resize the image for you to fit the maximum width of the screen:

    
    

    Resizing its height to WebView's viewport is possible too:

    
    

    However, resizing both width and height would result in a stretched image. To either resize the width or height depending of what side fits best you may consider a bit of JavaScript, like this:

    
    
    
    
    

提交回复
热议问题