I am using relativelayout and inside it a scrollview and inside it a linear layout and a textview which is ensuring scrolling of textview, but I do not want to scroll the text after the particular condition. So, what can I do for this?
Asked
Active
Viewed 2.4k times
3 Answers
10
To make the scrollbars invisible use this attribute.
android:scrollbars="none"
Edit:
if there is need of runtime changes on visibility or state of enabling, for that we can use the scrolview.setEnabled(false)
or android:enabled=false
.

Praveen
- 90,477
- 74
- 177
- 219
-
I am asking to scrolling to get disable when particular condition gets false.So, changes must be done in source code – Nikki Dec 03 '10 at 07:40
-
3then use `android:enabled=false` or `scrolview.setEnabled(false);` – Praveen Dec 03 '10 at 09:44
-
Kindly update this comment to your answer,such that viewer can see it first time – sonu thomas Jan 12 '12 at 07:07
8
There is no direct way to stop scrollview to scroll but u can do it in other way Like:
//global boolean variable
boolean enable = true;
scrollview.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
return !enable;
}
});
when you set enable variable to true it will start scrolling and when you set it to false it stop scrolling.

Leandro Keen Zapa
- 186
- 1
- 11

Saubhagya Chaudhary
- 129
- 1
- 3
-
this is the best answer. I don't know why is the other answer accepted. This one should be accepted as real answer. I've tried previous, and it's not working. setEnabled on a ScrollView is not applicable. This listener works flawlessly. Thanks! – Reinherd Mar 28 '13 at 10:20
-
Here's a better code for the answer in another question: http://stackoverflow.com/a/5090420/887894 – Anonsage Jun 04 '13 at 19:24
1
If I interpreted your question correctly, you probably want to extend ScrollView and write your own implementation of onInterceptTouchEvent. You could then make your ScrollView conditionally ignore touch events, thus disabling the scrolling behavior. See this question for more details.

Community
- 1
- 1

Jason Plank
- 2,336
- 5
- 31
- 40