开发者

How can i disable a scrollview?

开发者 https://www.devze.com 2023-01-28 12:02 出处:网络
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 s开发者_高级运维croll the text after the

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 s开发者_高级运维croll the text after the particular condition. So, what can I do for this?


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消