Home » Android » ListView inside ScrollView is not scrolling on Android

ListView inside ScrollView is not scrolling on Android

Posted by: admin March 10, 2020 Leave a comment


I am having trouble with a scrolling ListView inside a ScrollView. I have an Activity which has some EditTexts in the top part and then a tab host with two tabs which have one ListView each. When the EditText views are focused, the soft keyboard comes up and as I have a ScrollView, the content is scrollable. But the problem comes when there are more items in ListViews (ones in tabs), I am not able to scroll the ListView, even if there are more items.

The following is the layout XML:

Please can anyone tell me what the problem is here? I have another post on the ListView inside ScrollView problem, but they were of no use in my case.

How to&Answers:

You shouldn’t put a ListView inside a ScrollView because the ListView class implements its own scrolling and it just doesn’t receive gestures because they all are handled by the parent ScrollView. I strongly recommend you to simplify your layout somehow. For example you can add views you want to be scrolled to the ListView as headers or footers.


Starting from API Level 21 (Lollipop) nested scroll containers are officially supported by Android SDK. There’re a bunch of methods in View and ViewGroup classes which provide this functionality. To make nested scrolling work on the Lollipop you have to enable it for a child scroll view by adding android:nestedScrollingEnabled="true" to its XML declaration or by explicitly calling setNestedScrollingEnabled(true).

If you want to make nested scrolling work on pre-Lollipop devices, which you probably do, you have to use corresponding utility classes from the Support library. First you have to replace you ScrollView with NestedScrollView. The latter implements both NestedScrollingParent and NestedScrollingChild so it can be used as a parent or a child scroll container.

But ListView doesn’t support nested scrolling, therefore you need to subclass it and implement NestedScrollingChild. Fortunately, the Support library provides NestedScrollingChildHelper class, so you just have to create an instance of this class and call its methods from the corresponding methods of your view class.


I found a solution that works excellently and can scroll the ListView without problems:

What this does is disable the TouchEvents on the ScrollView and make the ListView intercept them. It is simple and works all the time.


I have also one solution. I always use this method. Try this

NestedListView.java class:


You have to just replace your <ScrollView ></ScrollView> with this Custom ScrollView like <com.tmd.utils.VerticalScrollview > </com.tmd.utils.VerticalScrollview >


I had a same issue and while googling I found your question. Yes marked answer worked for me also but there was some issue.
Anyways I found another solution.
which works perfectly without doing any jugglery.



Here is the exact method of using Listview with in the Scrollview. All we have to handle touch events.


Use the following method and enjoy!

listViewTouchAction is a global integer value.
If you can replace the line

with something else please share it with us.



Its a bad practice to have two different scrolling views together. ListView itself has its own scrolling functionality and height is auto adjusted according to Adapter settings for your row items (Keelping in mind, we are not setting specific height to ListView in our Layout xml). However in your case, you can replace ListView with a class and this will adjust height for your ListView keeping in mind that your ListView is inside ScrollView.

This will help you:

Now extend your ListView with this class, just change your ListView tag from your resource xml to smothing like this,

This will solve your scrolling problem of ListView, as now the parent scrolling is managed by ScrollView rather then ListView.


I’ve similar issue and resolved by creating custom class by extending with ListView.




I know this question is asked long ago, but who ever is stuck for now can solve this by adding this line into your ListView

For Example –








Helper class









The best solution is to use NestedScrollVew with RecyclerView or if you want to go with Listview then you can add header and footer view to this.
For example:


I have tried and tested nearly all the methods mentioned above, trust me, after completely running away from RecyclerView, I replaced my ListView with RecyclerView and it worked perfectly. Didnt need any 3rd Party library for ExtendedHeightListView and all, just plain and simple RecyclerView.

So Heres my Layout file before recyclerView:

THIS IS AFTER REPLACING MY LISTVIEW WITH ONE OF THE MANY SOLUTIONS MENTIONED ABOVE. So the problem was that the listview was not behaving properly due to 2 scrollview bug(maybe not a bug) in android.

I replaced the
with recycler view to form form my final layout.

This is my recycler view adapter:

And this is my RecyclerView custom layout:

And VOILA, I got the desired effect of ListView(Now RecyclerView) within a scollview.
Heres the Final Image of the UI

On a final note, I believe that replacing the RecyclerView was a better choice for me, as it improved the overall app stability, and also helped me understand RecyclerView better. If I were to suggest a solution, Im going to say replace your ListView with a RecyclerView.


Above solution given by @Shailesh Rohit works perfectly fine. Some tricks has to be done.

  1. If you are putting helper class inside the same class( main class) then make Helper class as static and getListViewSize() not be static.

  2. Most important, write “Helper.getListViewSize(listView);” statement after setting adapter for the first time like “listView.setAdapter(myAdapter);” as well as when ever you are using “myAdapter.notifyDataSetChanged();”

  3. Usage is shown below.

    listView = (ListView) findViewById(R.id.listView);
    myAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, listValues);
    listView .setAdapter(myAdapter);



As According to me while you are using setOnTouchListener om parent or child stop the scrolling of parent as you touch on child else stop scrolling of child as you touch on parent


Use this method and your listview become scrollable inside scrollview:-


Try this with ScrollView, not with ListView.


requestDisallowInterceptTouchEvent (boolean disallowIntercept)

Called when a child does not want this parent and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.

Try this answer,


replace ListView by RecycleView inside ScrollView. it runs smoothly without additional source code:


For ListView inside ScrollView use NestedScrollView it can handle this
functionality very easily:


I have had this error.And my solution is following as:

1. Create a custom listview which is non scrollable


2. Use above custom class for xml file

Hope best for you.


I found a solution for that,
Instead of using scrollview, You can use addHeaderview and addFooterview of listview

Here is my snippet,

Now, with the listview your layout also can be scrolled. Enjoy it!!!


Replace ScrollView by android.support.v4.widget.NestedScrollView inside xml. it runs

1) Use in XML:::: android.support.v4.widget.NestedScrollView

instead of:::: ScrollView

2) And use for list view in this way using NonScrollListView in cs file:

3) Finally use this code to identify scrollview in cs file:


Best Code




Dont give scroll view to ListView, coz it has that setting default


You cannot add a ListView in a scroll View, as list view also scolls and there would be a synchonization problem between listview scroll and scroll view scoll.
You can make a CustomList View and add this method into it.