Android向上和向下滑动以隐藏按钮

时间:2014-07-08 09:09:03

标签: android android-layout android-fragments

如何在Google +中实现滑动应用和向下滑动,我需要在片段中添加内容。任何想法?

enter image description here

1 个答案:

答案 0 :(得分:0)

我有2个解决方案:

  1. https://github.com/LarsWerkman/QuickReturnListView您可以自定义页脚视图。
  2. 你可以自己做。触发Listview或Gridview的onScrollListener

        listview.setOnScrollListener(new OnScrollListener() {
    
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
    
        }
    
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    
    
            if (view.getId() == listview.getId()) {
                final int currentFirstVisibleItem = mGrid.getFirstVisiblePosition();
                if (currentFirstVisibleItem > mLastFirstVisibleItem) {
                    Log.i("a", "scrolling down...");
                    if (mIsScrollingUp) {
                        mIsScrollingUp = false;
                        bottomView.setTranslationY(bottomHeight);
                    }
                } else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
                    Log.i("a", "scrolling up...");
                    if (!mIsScrollingUp) {
                        mIsScrollingUp = true;
                        bottomView.setTranslationY(0);
                    }
                }
    
                mLastFirstVisibleItem = currentFirstVisibleItem;
            }
    }
    
  3. 如果我的代码错误,请告诉我