简体   繁体   中英

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
        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");  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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