废话不多直接上代码
private boolean isShow=true;
nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//上滑 并且 正在显示底部栏
if (scrollY - oldScrollY > 0 && isShow) {
isShow = false;
//将Y属性变为底部栏高度 (相当于隐藏了)
View.animate().translationY(View.getHeight());
} else if (scrollY - oldScrollY < 0 && !isShow) {
isShow = true;
View.animate().translationY(0);
}
}
});