I need a way to make the Activity scrollable, but the ListViews unscrollable. I've tried different ways that I've found, but none of them have worked so far.
Asked
Active
Viewed 54 times
-1
-
3Can you give more details of why you'd want this? – advice Dec 18 '18 at 23:28
-
If you want a non-scrolling `View`, then there's really no point in using a `ListView`. Use a vertical `LinearLayout` instead. – Mike M. Dec 18 '18 at 23:30
2 Answers
0
Have you tried using NestedScrollView
? It works well with RecyclerView
, but I'm not sure about ListView
.
Try something like this.
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Your header above your list. -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Header" />
<!-- The list and it's contents. -->
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The footer below your list. -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Footer" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

advice
- 5,778
- 10
- 33
- 60
0
Could be better if you give more details.
We use ListView
when we have a list of items with different values. For scenarios that our views may overflow the screen and may not be visible, ScrollView
or in some situations NestedScrollView
are the answer to solve the problem. And remember to put all contents in a Layout tag like LinearLayout
and put it inside the ScrollView
.

Mohammad
- 792
- 1
- 7
- 15