How to always show scrollbar

AndroidScrollview

Android Problem Overview


The scrollbar in my scrollview is only visible when I start scrolling. How can I always show it?

Android Solutions


Solution 1 - Android

As of now the best way is to use android:fadeScrollbars="false" in xml which is equivalent to ScrollView.setScrollbarFadingEnabled(false); in java code.

Solution 2 - Android

Setting the android:scrollbarFadeDuration="0" will do the trick.

Solution 3 - Android

There are 2 ways:

  • from Java code: ScrollView.setScrollbarFadingEnabled(false);
  • from XML code: android:fadeScrollbars="false"

Simple as that!

Solution 4 - Android

Don't forget to add android:scrollbars="vertical" along with android:fadeScrollbars="false" or it won't show at all in some cases.

Solution 5 - Android

Style your scroll bar Visibility, Color and Thickness like this:

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/recycler_bg"

        <!--Show Scroll Bar-->
        android:fadeScrollbars="false"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbarFadeDuration="50000"

        <!--Scroll Bar thickness-->
        android:scrollbarSize="4dp"

        <!--Scroll Bar Color-->
        android:scrollbarThumbVertical="@color/colorSecondaryText"/>

Hope it help save some time.

Solution 6 - Android

Try this as the above suggestions didn't work for me when I wanted to do this for a TextView:

TextView.setScrollbarFadingEnabled(false);

Good Luck.

Solution 7 - Android

Try android:scrollbarAlwaysDrawVerticalTrack="true" for vertical. and Try android:scrollbarAlwaysDrawHorizontalTrack="true" for horizontal

Solution 8 - Android

Since neither of the above worked for me, here's what did: android:scrollbarDefaultDelayBeforeFade="500000"

Solution 9 - Android

android:scrollbarFadeDuration="0" sometimes does not work after I exit from the apps and start again. So I add gallery.setScrollbarFadingEnabled(false); to the activity and it works!

Solution 10 - Android

Simple and easy. Add this attribute to the ScrollBar:

android:fadeScrollbars="false"

Or you can do this in [tag:Java]:

scrollView.setScrollbarFadingEnabled(false);

Or in [tag:Kotlin]:

scrollView.isScrollbarFadingEnabled = false

Solution 11 - Android

These two together worked for me:

android:scrollbarFadeDuration="0"
android:scrollbarAlwaysDrawVerticalTrack="true"

Solution 12 - Android

I had the same problem. The bar had the same background color. Try:

android:scrollbarThumbVertical="@android:color/black"

Solution 13 - Android

setVertical* helped to make vertical scrollbar always visible programmatically

scrollView.setScrollbarFadingEnabled(false);
scrollView.setVerticalScrollBarEnabled(true);
scrollView.setVerticalFadingEdgeEnabled(false);

Solution 14 - Android

Setting this will do the trick. Change the @drwable for own style.

android:scrollbars="vertical"
            android:scrollbarAlwaysDrawVerticalTrack="true"
            android:fadeScrollbars="false"
            android:scrollbarThumbVertical="@drawable/scroll"`

Solution 15 - Android

use awakenScrollBars() awake scrollbar draw.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjulView Question on Stackoverflow
Solution 1 - AndroidRejinderiView Answer on Stackoverflow
Solution 2 - AndroidTanmay MandalView Answer on Stackoverflow
Solution 3 - AndroidTudor LucaView Answer on Stackoverflow
Solution 4 - AndroidSir CodesalotView Answer on Stackoverflow
Solution 5 - AndroidHitesh SahuView Answer on Stackoverflow
Solution 6 - AndroidCamille SévignyView Answer on Stackoverflow
Solution 7 - AndroidSaurabh PareekView Answer on Stackoverflow
Solution 8 - AndroidEmir KuljaninView Answer on Stackoverflow
Solution 9 - AndroidicegeeView Answer on Stackoverflow
Solution 10 - AndroidGouravView Answer on Stackoverflow
Solution 11 - AndroidsealskejView Answer on Stackoverflow
Solution 12 - AndroidBoris KarloffView Answer on Stackoverflow
Solution 13 - AndroidDmitry BryliukView Answer on Stackoverflow
Solution 14 - AndroidMuthu KrishnanView Answer on Stackoverflow
Solution 15 - Android李亮亮View Answer on Stackoverflow