国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 中實現ListView滑動隱藏標題欄的代碼

2019-12-12 03:59:37
字體:
來源:轉載
供稿:網友

布局中listview要覆蓋標題欄

 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.xml文件

<dimen name="titlepage_height">45dp</dimen>

以上所述是小編給大家介紹的Android ListView滑動隱藏標題欄的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁蒗| 贺州市| 元江| 富裕县| 望谟县| 文成县| 东城区| 苍梧县| 马边| 台江县| 贞丰县| 东乡县| 兴宁市| 普宁市| 方城县| 绥化市| 衡阳市| 咸阳市| 阿图什市| 大庆市| 棋牌| 东至县| 灯塔市| 泰和县| 刚察县| 彭山县| 田林县| 文登市| 乌鲁木齐市| 浮梁县| 宝兴县| 新营市| 西华县| 嵊泗县| 定安县| 合水县| 泽库县| 枣强县| 莱西市| 留坝县| 德令哈市|