这是总体思路。
活动:
public void setupMovingBar(final Boolean full) {
final Display dWidth = getWindowManager().getDefaultDisplay();
appBarLayout.post(new Runnable() {
@Override
public void run() {
int heightPx = dWidth.getHeight();
if (!full) {
heightPx = dWidth.getHeight() - (dWidth.getHeight() * 1 / 3);
}
setAppBarOffset(heightPx);
}
});
}
private void setAppBarOffset(int offsetPx) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
behavior.onNestedPreScroll(clContent, appBarLayout, null, 0, offsetPx, new int[]{0, 0});
}