93

I have an app with a ScrollView, and I don't want the scrollbar to appear on the screen. How can I hide the scrollbar in a ScrollView while making sure scrolling still works?

enter image description here

live-love
  • 48,840
  • 22
  • 240
  • 204
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133
  • Possible duplicate of [Remove scroll bar track from ScrollView in Android](https://stackoverflow.com/questions/6273335/remove-scroll-bar-track-from-scrollview-in-android) – Erick Petrucelli Dec 03 '18 at 12:42

11 Answers11

222

In Java add this code:

myScrollView.setVerticalScrollBarEnabled(false);
myScrollView.setHorizontalScrollBarEnabled(false);

In XML add following attribute to your ScrollView:

android:scrollbars="none"

Like this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainScroll"
android:scrollbars="none" <!-- line to be added -->
>
live-love
  • 48,840
  • 22
  • 240
  • 204
Umar Qureshi
  • 5,985
  • 2
  • 30
  • 40
41

This will hide the Scroll bar stick but scroll bar is not disable

android:scrollbarThumbVertical="@null"

android:scrollbarThumbHorizontal="@null"

This will disable the scroll bar

android:scrollbars="none"
Kishor N R
  • 1,521
  • 1
  • 17
  • 23
  • 2
    `android:scrollbars="none"` does not disable scrollbars.you can scroll but just hides ` scrollview stick` – MMK Nov 14 '18 at 08:44
17

In XML set android:scrollbars="none"

Talha Ahmed Khan
  • 15,043
  • 10
  • 42
  • 49
Ramesh Akula
  • 5,720
  • 4
  • 43
  • 67
8

Try this, it is also working...

android:scrollbarThumbVertical="@null"

or

android:scrollbarThumbHorizontal="@null"
User
  • 4,023
  • 4
  • 37
  • 63
5

In my experience,

android:scrollbarThumbVertical="@null"

can cause NullPointerException in older devices. Use this instead:

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

Cheers!

user1506104
  • 6,554
  • 4
  • 71
  • 89
4

you have to try the following solutions

    android:scrollbars="none"

OR

    android:scrollbarThumbVertical="@null"
    android:scrollbarThumbHorizontal="@null"

OR Change color of scrollBars to hide them

    android:scrollbarThumbVertical="@android:color/transparent"
Shubham Sharma
  • 166
  • 1
  • 7
3

For hiding a vertical scrollbar, do this in the XML:

android:scrollbarThumbVertical="@null"

And for Hiding horizontal scrollbar do this :

android:scrollbarThumbHorizontal="@null"

The above lines of codes will work if you want to hide the scrollbar without disabling it.

And for disabling a scrollbar, write this:

android:scrollbars="none"
Zoe
  • 27,060
  • 21
  • 118
  • 148
saurabh gupta
  • 491
  • 6
  • 18
2

Now the scroll does not work anymore if u set android:scrollbars="none"

I have solved the problem with

  android:scrollbars="vertical" // or horizontal

and setting its size to 0 dp

  android:scrollbarSize="0dp"
Matej Vukosav
  • 666
  • 8
  • 12
2

Kotlin Solution

If you need to do this programmatically, you can set either one or both of:

scrollView.isHorizontalScrollBarEnabled = false
scrollView.isVerticalScrollBarEnabled = false

If you'll be applying both regularly, try adding this extension

fun ScrollView.noScrollbars() {
    isHorizontalScrollBarEnabled = false
    isVerticalScrollBarEnabled = false
}

To easily allow switching, you can add an optional boolean

fun ScrollView.noScrollbars(hide: Boolean = true) {
    isHorizontalScrollBarEnabled = !hide
    isVerticalScrollBarEnabled = !hide
}
Gibolt
  • 42,564
  • 15
  • 187
  • 127
2

In the XML layout, add this property:

android:scrollbarSize="0dp"
Zoe
  • 27,060
  • 21
  • 118
  • 148
Maneesh
  • 6,098
  • 5
  • 36
  • 55
1

If you are making "custom" HorizontalScrollView then you should set those properties in code like so

this.scrollBarSize = 0 this.isHorizontalScrollBarEnabled = false

That is the only way I got mine to work.

saintjab
  • 1,626
  • 20
  • 31