我希望将SwipeRefreshLayout
放在包含CoordinatorLayout
的{{1}}之外。当我向上滚动到顶部时,CollapsingToolbarLayout
正常工作(折叠内部视图)。但我向下滚动,它没有扩展视图,它显示刷新图标刷新。
我怎么能向下滚动,它会扩展视图,然后刷新图标。
CollapsingToolbarLayout
答案 0 :(得分:5)
您可以处理AppBarLayout
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
public enum State {
EXPANDED,
COLLAPSED,
IDLE
}
private State mCurrentState = State.IDLE;
@Override
public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
if (i == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE);
}
mCurrentState = State.IDLE;
}
}
public abstract void onStateChanged(AppBarLayout appBarLayout, State state);
}