Android WebView, Scaling Image to fit the screen

前端 未结 9 1154
醉梦人生
醉梦人生 2020-11-29 01:13

What I have: I\'m loading image from a URL. I simply do (WebView).loadUrl(imageurl, extraheaders)

What I get: Image i

9条回答
  •  广开言路
    2020-11-29 01:49

    I had the same issue and doing this worked just fine:

    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    
    String data = "Example";
    data = data + "
    "; webView.loadData(data, "text/html", null);

    Edit: As this remained as the accepted answer, here is a better solution (all credit to Tony below):

    WebView content = (WebView) findViewById(R.id.webView1);
    content.loadDataWithBaseURL(null, "" + post.getContent(), "text/html", "UTF-8", null);
    

提交回复
热议问题