Android Webview Image Render to Center instead of top left

The image in the webview starts from the upper left corner of my image, which is larger than the webview, so it scrolls. I would like to focus the image, not the rendering in the upper left corner ... is there any way to do this?

+4
source share
2 answers

You can find your answer in this post here: WebView scrolling not working

He solved my problems.

+1
source

Instead of calling myWebView.loadUrl, you can use simple CSS and call myWebView.loadData instead.

Just make sure the URL encodes any extraneous characters. Example:

myWebView.loadData("<html><head><style type='text/css'>body{margin:auto auto;text-align:center;} img{width:100%25;} </style></head><body><img src='www.mysite.com/myimg.jpeg'/></body></html>" ,"text/html", "UTF-8"); 
0
source

All Articles