Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 438
weakwire Avatar asked Jan 18 '12 20:01

weakwire


People also ask

How to hide scrollbar in ScrollView Android Studio?

If you have scroll element on your Android Intent like HorizontalScrollView, TextView or elements inside ScrollView, and you do not want the ScrollBar to be not visible when the element is scrolled just add the below line to your element XML tag.

How to hide scrollbar in ListView Android?

setHorizontalScrollBarEnabled(boolean) - disable \ enable horizontal scrollbars. Show activity on this post. This is the property you should use on your ListView . All the best.

How do I turn off scroll view?

You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched.


2 Answers

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

view.setVerticalScrollBarEnabled(false);
view.setHorizontalScrollBarEnabled(false);
like image 84
Viking Avatar answered Sep 29 '22 17:09

Viking


In java add this code:

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

In xml add following attribute to your ScrollView:

android:scrollbars="none"
like image 36
Makvin Avatar answered Sep 29 '22 19:09

Makvin