How to show the Scrollbar in a NestedScrollView

Kokusho picture Kokusho · Sep 25, 2016 · Viewed 11k times · Source

Hey i implemented a NestedScrollView in an Activity, but i cant show the scrollbar like i do in a ScrollView, can you guys.

How can I show it?

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/appBar">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:orientation="vertical"
            android:paddingLeft="@dimen/dimen_2"
            android:paddingRight="@dimen/dimen_2">
        </LinearLayout>
</android.support.v4.widget.NestedScrollView>

Answer

Michael Peterson picture Michael Peterson · Sep 20, 2017

Use the android:scrollbars attribute.

Such as:

android:scrollbars="vertical"

android:scrollbars="horizontal"

android:scrollbars="vertical|horizontal"

For example:

<android.support.v4.widget.NestedScrollView
    android:id="@+id/foo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical">

</android.support.v4.widget.NestedScrollView>
    

Documentation link: https://developer.android.com/reference/android/view/View.html#attr_android:scrollbars