Utwórz niestandardowy ScrollView i używaj go w dowolnym miejscu.
class CustomScrollView extends ScrollView {
// true if we can scroll the ScrollView
// false if we cannot scroll
private boolean scrollable = true;
public void setScrollingEnabled(boolean scrollable) {
this.scrollable = scrollable;
}
public boolean isScrollable() {
return scrollable;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
// if we can scroll pass the event to the superclass
if (scrollable) return super.onTouchEvent(ev);
// only continue to handle the touch event if scrolling enabled
return scrollable; // scrollable is always false at this point
default:
return super.onTouchEvent(ev);
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Don't do anything with intercepted touch events if
// we are not scrollable
if (!scrollable) return false;
else return super.onInterceptTouchEvent(ev);
}
}
ten może być użyty w układzie
<com.packagename.CustomScrollView
android:id="@+id/scrollView"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</com.packagename.CustomScrollView >
Następnie wywołać
((CustomScrollView)findViewById(R.id.scrollView)).setIsScrollable(false);
mam wklejony tego rozwiązania, to nie chce działać. –
działa, ale teraz nie mogę przewinąć mojego zagnieżdżonego przewijania albo .. – DrNachtschatten