【发布时间】:2015-11-13 03:51:18
【问题描述】:
我有一个嵌套的子滚动视图,它设置为禁用滚动,直到父滚动视图完成向上滚动。设置childScrollView.setNestedScrollingEnabled(false) 最初有效,并在父级完全向上滚动后重新启用childScrollView.setNestedScrollingEnabled(true)。但是,虽然这正在工作,但我想在父级滚动到底部后再次禁用嵌套滚动视图,但它不起作用。有什么想法吗?
MainActivity (sn-p):
ResponsiveScrollView parentScroll = (ResponsiveScrollView) findViewById(R.id.parentScroll);
final ScrollView childScroll = (ScrollView) findViewById(R.id.childScroll);
childScroll.setNestedScrollingEnabled(false); // disabled by default
parentScroll.setOnEndScrollListener(new PriorityNestedScrollView.OnEndScrollListener() {
@Override
public void onUpEndScroll() {
Log.i(TAG, "scrolling up has ended"); // successfully fires
childScroll.setNestedScrollingEnabled(true); // working...
}
@Override
public void onDownEndScroll() {
Log.i(TAG, "scrolling down has ended"); // successfully fires
childScroll.setNestedScrollingEnabled(false); // not working...
}
});
响应式滚动视图(sn-p):
@Override
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
super.onScrollChanged(x, y, oldX, oldY);
// scroll up ended
if (y >= END) {
if (onEndScrollListener != null) {
onEndScrollListener.onUpEndScroll();
}
}
// scroll down ended
if (y <= START) {
if (onEndScrollListener != null) {
onEndScrollListener.onDownEndScroll();
}
}
}
【问题讨论】:
标签: android android-scrollview