17

How can I remove the scroll bar from a ScrollView programmatically?

setScrollBarStyle() only changes only the style of the scrollbar.

I want to access the xml attribute android:scrollbars programmatically. Is there any way to do that?

android:scrollbars Defines which scrollbars should be displayed on scrolling or not.

Cœur
  • 34,719
  • 24
  • 185
  • 251
weakwire
  • 9,249
  • 8
  • 52
  • 78
  • Related/dupe: [Hide Scrollbar of HorizontalScrollView](http://stackoverflow.com/questions/12258814/hide-scrollbar-of-horizontalscrollview) – blahdiblah Oct 09 '14 at 23:08

2 Answers2

56

The following two method calls will remove the scrollbars in your scrollview:

view.setVerticalScrollBarEnabled(false);
view.setHorizontalScrollBarEnabled(false);
Community
  • 1
  • 1
Viking
  • 862
  • 10
  • 16
4

In java add this code:

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

In xml add following attribute to your ScrollView:

android:scrollbars="none"
Gaëtan Maisse
  • 11,973
  • 9
  • 44
  • 46
Makvin
  • 3,083
  • 24
  • 26