Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are different ways to utilize a ListView in a ScrollView without showing a scrollbar:

  1. Disable the Scrollbar: You can disable the scrollbar of the ScrollView by setting the android:scrollbars attribute to none.
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null"
        android:overScrollMode="never"
        android:scrollbarStyle="outsideOverlay"/>

</ScrollView>
  1. Set the ListView Height: Set the height of the ListView to wrap_content so that it only occupies the required height, and it will not require scrolling.
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null"
        android:overScrollMode="never"
        android:scrollbarStyle="outsideOverlay"/>

</ScrollView>
  1. Use NestedScrollingEnabled: Enable nested scrolling of the ListView by adding the android:nestedScrollingEnabled attribute to the ListView.
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null"
        android:overScrollMode="never"
        android:nestedScrollingEnabled="true"
        android:scrollbarStyle="outsideOverlay"/>

</ScrollView>

Using any of the above methods, the ListView can be utilized in a ScrollView without a scrollbar.