-1

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.

Daniel
  • 2,355
  • 9
  • 23
  • 30
dannyk
  • 31
  • 4

2 Answers2

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