Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:48:41+00:00 2026-06-17T12:48:41+00:00

I have a Custom ListView with a webView inflated in it. here is XML

  • 0

I have a Custom ListView with a webView inflated in it. here is XML code

reader_layout.xml

 <ListView
    android:id="@+id/listReader"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/readerHeader"
    android:divider="@android:color/background_dark"
    android:dividerHeight="5dp" >
</ListView>

reader_list_webview.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >
<WebView
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:scrollbars="none" />
</RelativeLayout>
  • I am using the AsyncTask and BaseAdapter to fill the listView with WebView, and I have loaded different URL in each webView. here is the java Code.

        public class ImageAdapter extends BaseAdapter {
    
        public ImageAdapter(Context c) {
        context = c;
    }
    
    // ---returns the number of images---
    public int getCount() {
        return URLs.size();
    }
    
    public ImageAdapter(Context ctx, Activity act) {
        inflater = (LayoutInflater) act
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    
    // ---returns the ID of an item---
    public Object getItem(int position) {
        return position;
    }
    
    public long getItemId(int position) {
        return position;
    }
    
    // ---returns an ImageView view---
    public View getView(final int position, View convertView,
            ViewGroup parent) {
    
        // ImageView bmImage;
    
        final ViewHolder holder;
        View vi = convertView;
        if (convertView == null) {
            vi = inflater.inflate(R.layout.book_reader_list_style, parent,
                    false);
            holder = new ViewHolder();
    
            holder.webView = (WebView) vi.findViewById(R.id.webView1);
    
            WebSettings webSettings = holder.webView.getSettings();
            webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
            holder.webView.setVerticalScrollBarEnabled(false);
            holder.webView.setHorizontalScrollBarEnabled(false);
            holder.webView.setVisibility(View.VISIBLE);
            webSettings.setLoadWithOverviewMode(true);
            webSettings.setUseWideViewPort(false);
            holder.webView.setInitialScale(scaleWebView);
    
            vi.setTag(holder);
        } else {
    
            holder = (ViewHolder) vi.getTag();
        }
        holder.webView.loadUrl((URLs.get(position)));
    
        return vi;
    
    }
    

    }

    class ViewHolder
    {
    WebView webView;
    }

Everything is working fine. But problem is that some URLs becomes very wider then the webview size hence they doesn’t fit the device screen width and some URLs load small pages hence we need to set zoom of webview.

  • I want to set the Zoom/scale of the webView according to the size of URLs page dynamically. so that user should not use zoom in or Zoom out.

I have tried this

android:layout_width="match_parent"
android:layout_height="match_parent"

and this

myWebview.setLoadWithOverviewMode(true);
myWebview.setUseWideViewPort(true);

and this also

holder.webView.setInitialScale(percent);

but it doesn’t resolve my requirements.

Edit

if I m setting setLoadWithOverviewMode(true/false); to true my app crashes and here is the Logcat

01-08 16:16:56.600: E/AndroidRuntime(8666): java.lang.IllegalArgumentException: bitmap size exceeds 32bits
  • actually my webview loads images of 491X600 upto 300X500 in size. how can i resize the images or something like that?
    but when i set setLoadWithOverviewMode(true/false); to false it working fine but problem is that the webview doesn’t re size to fit the width of screen.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:48:42+00:00Added an answer on June 17, 2026 at 12:48 pm

    Finally I sorted out my solution myself. Here it is

    holder.webView.loadDataWithBaseURL(null,"<!DOCTYPE html><html><body style = \"text-align:center\"><img style=\"border-style:dotted;border-width:5px;border-color:black;width:99%;\" src= "  + URLs.get(position)+ " alt=\"page Not Found\"></body></html>","text/html", "UTF-8", null)
    

    it will exactly fit the webView’s tag fill the screen. no matter your phone is 230X480 or u have any android tablet of 800X1200 .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom listView.xml having a listView as. <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
I have created a custom listView with the row as follows: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
Here's my aproach: I have a custom ListView containing a custom Adapter containing two
I have a custom listview defined in my xml layout file. I can add
I want to hide image from ListView , Here i have used custom listview
I have a custom listView. The main layout xml is something like this: <?xml
I have one custom ListView called AreasListView which I've included in the XML file.
Hi I have a Custom ListView with one ImageView and TextView . Here is
In android application i have a custom listview and sqlite database. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.