Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to disable a scrollView?
- scrollView.setEnable(false);
- scrollView.setOnTouchListener(null);
- scrollView.requestDisallowInterceptTouchEvent(true);
- <ScrollView
- android:id="@+id/mainPage_scroll"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentRight="true"
- android:focusableInTouchMode="true"
- android:layout_below="@+id/tabBar" >
- </ScrollView>
- //removed an invalid option/answer
- scrollView.setVisibility(Visibility.GONE);
- class LockableScrollView extends ScrollView {
- ...
- // true if we can scroll (not locked)
- // false if we cannot scroll (locked)
- private boolean mScrollable = true;
- public void setIsScrollable(boolean scrollable) {
- mScrollable = scrollable;
- }
- public boolean getIsScrollable()
- return mScrollable;
- }
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- switch (ev.getAction()) {
- case MotionEvent.ACTION_DOWN:
- // if we can scroll pass the event to the superclass
- if (mScrollable) return super.onTouchEvent(ev);
- // only continue to handle the touch event if scrolling enabled
- return mScrollable; // mScrollable is always false at this point
- default:
- return super.onTouchEvent(ev);
- }
- }
- }
- <com.mypackagename.LockableScrollView
- android:id="@+id/QuranGalleryScrollView"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent">
- <Gallery android:id="@+id/Gallery"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:scrollbars="horizontal">
- </Gallery>
- </com.mypackagename.LockableScrollView>
- ((LockableScrollView)findViewById(R.id.QuranGalleryScrollView)).setIsScrollable(false);
Advertisement
Add Comment
Please, Sign In to add comment