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 4381884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:42:25+00:00 2026-05-21T12:42:25+00:00

I am currently trying to use a ListView inside of a ScrollView. I know

  • 0

I am currently trying to use a ListView inside of a ScrollView. I know from what I’ve read that this is looked down upon, but I’m trying to get the ListView to expand completely by showing all of its rows so there is no need for it to scroll. I’ve been struggling, however, with how to tell the ListView to completely expand to show all of its rows since it needs a defined height. How do I calculate the height of a fully expanded ListView before it is drawn?

This problem mainly stems from the fact that you can’t put a scrollable view inside of another scrollable view. I am okay with the fact that the ListView won’t be able to scroll as long as I can make it expand to show all of its rows. I cannot do this, however, without being able to give it a defined height, which it seems I would need to calculate.

My full layout is too big for the “physical” screen and needs to scroll in order to show the rest of the list and buttons at the bottom. I’m trying to get across that the “virtual” screen is too big to fit on one screen even without the ListView there.

  • 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-05-21T12:42:26+00:00Added an answer on May 21, 2026 at 12:42 pm

    Well, thanks to Rudy, his suggestions was very helpful. Here is how it can be implemented.

    1) Create a new class that extends ListView:

    package com.example.android.views;
    
    import android.content.Context;
    import android.graphics.Canvas;
    import android.util.AttributeSet;
    import android.widget.ListView;
    
    public class ExpandedListView extends ListView {
    
        private android.view.ViewGroup.LayoutParams params;
        private int old_count = 0;
    
        public ExpandedListView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            if (getCount() != old_count) {
                old_count = getCount();
                params = getLayoutParams();
                params.height = getCount() * (old_count > 0 ? getChildAt(0).getHeight() : 0);
                setLayoutParams(params);
            }
    
            super.onDraw(canvas);
        }
    
    }
    

    2) … and finally add the new view to your xml layout file:

    <com.example.android.views.ExpandedListView
        android:id="@+id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scrollbars="none"
        android:padding="0px"
        />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use VS 2008 Professional, but I'm trying to get Team System Developer
I am currently trying to use Eclipse to develop some code that I've been
I am currently trying to use NAnt and CruiseControl.NET to manage various aspects of
I currently trying to find a solution, how to ensure that a test fails
I'm currently trying to read in an XML file, make some minor changes (alter
Im currently trying to use a jQuery plugin: jQuery Autocomplete Tokenizer Now after posting
I'm currently trying to use jQuery to fade a particular div which contains a
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying to build a personal website to create a presence on the
I'm currently trying to port a SIP stack library (pjSIP) to the PSP Console

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.