Android: Easiest way to make a WebView display a Bitmap?

后端 未结 2 374
暗喜
暗喜 2021-01-12 11:57

I have some images that I loaded from a remote source stored in Bitmap variables and I want to display them. In addition to switching between these images the user should al

2条回答
  •  借酒劲吻你
    2021-01-12 12:05

    You can just use webview to directly view your image remotely. You do not need to save anymore the image in a file. Here is a sample code snippet.

    myWebView.getSettings().setBuiltInZoomControls(true); //to get zoom functionalities
    
    String url = "http://....."; //url of your image
    
    String x= "
    "; myWebView.loadData(x, "text/html", "UTF-8");

    About switching images, you can just change the value of the url and call the loadData again of the webview.

提交回复
热议问题