weakwire
weakwire

Reputation: 9300

Remove scrollbar from ScrollView programmatically in Android

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.

Upvotes: 18

Views: 14584

Answers (2)

Viking
Viking

Reputation: 866

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

view.setVerticalScrollBarEnabled(false);
view.setHorizontalScrollBarEnabled(false);

Upvotes: 58

Makvin
Makvin

Reputation: 3629

In java add this code:

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

In xml add following attribute to your ScrollView:

android:scrollbars="none"

Upvotes: 4

Related Questions