I am using CoordinatorLayout
in my activity page. In that there is ListView
below the app bar. But its not working when I use ListView
instead of NestedScrollView
. And if I put ListView
inside NestedScrollView
, ListView
is not expanding

- 929
- 1
- 14
- 36

- 3,941
- 5
- 36
- 62
-
2http://stackoverflow.com/a/6211286 – Sree Oct 01 '15 at 06:57
10 Answers
you can fix it when you add addtribute
android:fillViewport="true"
in android.support.v4.widget.NestedScrollView
:) . This my code.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
>
<ListView
android:id="@+id/list_myContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
>
</ListView>
</android.support.v4.widget.NestedScrollView>

- 19,129
- 42
- 60
- 98

- 1,011
- 1
- 8
- 8
-
26Didn't worked for me too. The ListView content isn't scrollable. – Luis E. Fernandez Jan 24 '16 at 18:50
-
-
6
-
android:fillViewport="true" works like a charm. Also keep in mind that a recycler view may be more appropriate in most cases (e.g. the whole list or individual items updates dynamically at runtime). – txedo Mar 30 '16 at 11:20
-
Worked with me So Thanks , you are really saved my time. just Added the tag android:fillViewport="true" – Waleed A. Elgalil Jun 14 '16 at 00:49
-
Worked for me +1. I have a ConstraintLayout within the NestedScrollView and it didn't scale up to full height without that flag. – Jürgen 'Kashban' Wahlmann Nov 30 '16 at 08:58
-
Try enabling programmatically like "nestedScrollView.setNestedScrollingEnabled(true);" – james Dec 16 '16 at 08:18
-
-
4
on Lollipop onwards you can use
setNestedScrollingEnabled(true);
on your ListView/GridView/ScrollableView. From the documentation
Enable or disable nested scrolling for this view
if you need backwards compatibility with older version of the OS you'll have to use the RecyclerView
. You can read more here
Edit.
ViewCompat
has the static method setNestedScrollingEnabled(View, boolean)
. Eg.
ViewCompat.setNestedScrollingEnabled(listView, true)
thanks to @Dogcat
for pointing it out

- 156,034
- 29
- 297
- 305
-
2This answer should definitely be upvoted and even set as the correct answer now. I ended up changing my implementation to a `RecyclerView` because I only read the answer that was accepted as the answer. Yes of course I could've read all the answers, but the first one worked for me - if was just a hassle to change the implementation ;-) – Darwind Nov 08 '16 at 19:28
-
1
-
No, it's not working. Docs say "If this view does not implement nested scrolling this will have no effect." – k4dima Sep 04 '17 at 13:57
-
2The ViewCompat does nothing before Android Lolipop: https://stackoverflow.com/questions/32811121/listview-nested-scrolling-on-api21 – Hrk Oct 17 '17 at 07:37
For the CoordinatorLayout
to work properly you need the scrolling child to implement NestedScrollingChild. Such classes are NestedScrollView
and RecyclerView
.
To say it short - just use a RecyclerView
for your scrolling content and it'll work correctly :)
P.S. As a side note, I don't see a reason why you'd use a ListView
anymore. I know it's a habit and it's easier to setup (because you've done it many times), but using a RecyclerView
is the recommended way anyways.

- 3,750
- 2
- 23
- 29
-
1I dont see a fastscroll and section adapter implementation for recycler view yet – sha Nov 02 '15 at 01:28
-
1
-
7RecyclerView doesn't handle the CursorAdapter. This could be a good reason! – Blodhgard Dec 27 '15 at 19:03
-
You could use Shywims custom CursorRecyclerView Adapter: https://gist.github.com/Shywim/127f207e7248fe48400b – Irritator Jan 06 '16 at 07:48
-
more details on should or should we not replace ListView with Recycler view http://stackoverflow.com/questions/28392554/should-we-use-recyclerview-to-replace-listview – Ivan Milisavljevic Feb 20 '17 at 18:53
-
Calling ViewCompat.setNestedScrollingEnabled(listView, true) does the trick with a ListView. – Dogcat Mar 07 '17 at 12:14
-
@Dogcat no, it's not. Docs "If this view does not implement nested scrolling this will have no effect." – k4dima Sep 04 '17 at 13:56
-
"I don't see a reason why you'd use a ListView anymore" Can't you just answer the ... question? – Jacob Sánchez Mar 25 '19 at 01:43
this is what worked for me.
set android:fillViewport="true"
on the NestedScrollView
add One Layout Element as Child to NestedScrollView
. In my case LinearLayout
and then
set android:nestedScrollingEnabled="true"
on ListView
Make ListView
a child of LinearLayout
Good to go

- 151
- 1
- 4
-
1I was about to say the same thing until I read this. This solution is good for API 21+ – zuko May 14 '18 at 04:01
-
Only solution that's worked for me. And Using the LinearLayout helps in composing a composite ui nested inside the outer NestedScrollView. Thanks! – JWL Dec 10 '19 at 12:28
Just put android:fillViewport="true"
inside you NestedScrollView
Tag

- 492
- 5
- 18
-
Please explain how your answer solves the problem, it will help everyone understand your solution with more clarity and for future reference. – Aziz Apr 03 '16 at 12:13
-
@Aziz actually I was also facing same problem and it worked. on setting "fillViewport" true it stretch the content's height to the viewport's boundaries, – Shivam Apr 04 '16 at 17:37
You listview will scroll. Hope help.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true">
</ListView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

- 2,542
- 19
- 29
Below code worked for me:
ViewCompat.setNestedScrollingEnabled(listView, true);
Your ListView
should be inside NestedScrollView

- 929
- 1
- 14
- 36

- 390
- 2
- 11
Replace your ListView with RecyclerView
if possible else create your customListView and set onMeasure
of ListView
to this:
public NonScrollListView(Context context) {
super(context);
}
public NonScrollListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
This ListView
won't be able to scroll anymore and can be used inside NestedScrollView
.

- 3,742
- 32
- 47
You can't scroll listview inside a nestedscrollview.Use Recyclerview with nestedscrollview
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:src="@drawable/profile"
app:border_color="#FF000000" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/profile_image"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IRFAN QURESHI"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="irfan123@gmail.com" />
</LinearLayout>
<ImageView
android:layout_marginLeft="50dp"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete_black" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@color/colorPrimary"
android:gravity="center_horizontal"
android:padding="30dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/login_email_bg_round_rect_shape"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="POST A QUERY" />
</LinearLayout>
<!--<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>-->
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<RelativeLayout
android:background="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:padding="8dp"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIGN OUT" />
<ImageView
android:paddingTop="5dp"
android:layout_marginRight="40dp"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete_black" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.NestedScrollView>

- 369
- 6
- 7
Just add android:nestedScrollingEnabled="true" tag inside your NestedScrollView.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:nestedScrollingEnabled="true">
<ListView
android:id="@+id/list_myContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</ListView>

- 2,521
- 1
- 11
- 8
-
1This one is only supported in API 21 and higher. Unfortunately I'm building for 16 minimum. – Keno Jan 31 '17 at 20:06