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
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With