Ask Your Question
4

How can a ListView be utilized in a ScrollView without a Scrollbar?

asked 2022-03-08 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-10 10:00:00 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-03-08 11:00:00 +0000

Seen: 13 times

Last updated: Oct 10 '22