简体   繁体   English

如何从URL适合webview中的图像

[英]How to fit the images in webview from url

Now i am working on a list view with webview.in this listview webview is using for showing images.and it is from the url.now i am facing a problem that from url i am not getting the unique dimension images,some images are small and some are large,while showing this tho webview it not properly arranged.how can i properly arrange/fit the webview images.i am using the following code. 现在我正在使用webview的列表视图。在此listview中,webview用于显示图像。它是从url开始的。现在我遇到一个问题,即从url无法获得唯一尺寸的图像,有些图像很小和一些是大的,而显示此tho webview时,它的排列不正确。我如何正确排列/适配webview图像。我正在使用以下代码。

<WebView
        android:layout_marginTop="5dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:id="@+id/webView"
         android:layout_width="55dp"
        android:layout_height="55dp" 

     >

code

WebView  webView = (WebView)view.findViewById(R.id.webView);
showImageOnWebView(webView, item.thumbimage,80,80);

Try this code . 试试这个代码。

  String r="<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0,target-densityDpi=device-dpi\">"; 

                       String s="<html><body style=\"margin: 0; padding: 0\"><IMG  width=\"100%\" height=\"100%\" src=\""+item.image+"\"><body><html>"; 


       webView.setBackgroundColor(0); 
       webView.setBackgroundResource(R.drawable.android); 
       webView.loadData(s, "text/html","UTF-8");  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM