int mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); //滑动监听 showHideTitleBar(true);
ListView standby_lv = (ListView) findViewById(R.id.standby_lv);
standby_lv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mFirstY = event.getY();
break;
case MotionEvent.ACTION_MOVE:
mCurrentY = event.getY();
if (mCurrentY - mFirstY > mTouchSlop) {
// 下滑 显示titleBar
showHideTitleBar(true);
} else if (mFirstY - mCurrentY > mTouchSlop) {
// 上滑 隐藏titleBar
showHideTitleBar(false);
}
break;
case MotionEvent.ACTION_UP:
break;
}
return false;
}
});
private Animator mAnimatorTitle;
private Animator mAnimatorTitlePage;
private Animator mAnimatorContent;
private void showHideTitleBar(boolean tag) {
if (mAnimatorTitle != null && mAnimatorTitle.isRunning()) {
mAnimatorTitle.cancel();
}
if (mAnimatorTitlePage != null && mAnimatorTitlePage.isRunning()) {
mAnimatorTitlePage.cancel();
}
if (mAnimatorContent != null && mAnimatorContent.isRunning()) {
mAnimatorContent.cancel();
}
if (tag) {
mAnimatorTitle = ObjectAnimator.ofFloat(mTitle, "translationY", mTitle.getTranslationY(), 0);
mAnimatorTitlePage = ObjectAnimator.ofFloat(mTitlePage, "translationY", mTitlePage.getTranslationY(), 0);
mAnimatorContent = ObjectAnimator.ofFloat(standby_lv, "translationY", standby_lv.getTranslationY(), getResources().getDimension(R.dimen.title_height));
} else {
mAnimatorTitle = ObjectAnimator.ofFloat(mTitle, "translationY", mTitle.getTranslationY(), -mTitle.getHeight());
mAnimatorTitlePage = ObjectAnimator.ofFloat(mTitlePage, "translationY", mTitlePage.getTranslationY(), -mTitlePage.getHeight());
mAnimatorContent = ObjectAnimator.ofFloat(standby_lv, "translationY", standby_lv.getTranslationY(), 0);
}
mAnimatorTitle.start();
mAnimatorTitlePage.start();
mAnimatorContent.start();
}
<dimen name="titlepage_height">45dp</dimen>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有