Example usage for android.view.animation TranslateAnimation TranslateAnimation

List of usage examples for android.view.animation TranslateAnimation TranslateAnimation

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation TranslateAnimation.

Prototype

public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:gov.whitehouse.ui.activities.BaseDashboardActivity.java

public void showSearch() {
    final int height = mSearchFragment.getView().getHeight();
    TranslateAnimation slideDownAnim = new TranslateAnimation(0, 0, -height, 0);
    slideDownAnim.setDuration(SEARCH_FRAGMENT_ANIMATION_DURATION);
    slideDownAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override//from  w ww .j a  v a2 s .  c  om
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            getSupportFragmentManager().beginTransaction().show(mSearchFragment).commitAllowingStateLoss();
            mSearchFragment.getView().requestLayout();
            mDrawerGarment.setDrawerEnabled(false);
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
            if (!mSearchField.getText().toString().equals("")) {
                mSearchFragment.setListShown(true);
                mSearchFragment.doSearchForQuery(mSearchField.getText().toString());
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mSearchFragment.getView().startAnimation(slideDownAnim);
    mShowingSearch = true;
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateScroller() {
    Timber.v("animateScroller()");
    checkNotNull(progressBar);// w  ww  . j  a  va2 s.  c  o m

    int animEnd = getWidth() - progressBarWidth;

    TranslateAnimation animation = new TranslateAnimation(0, animEnd, 0, 0);
    animation.setDuration(ANIMATION_SCROLL_DURATION);
    animation.setFillAfter(true);
    animation.setRepeatMode(Animation.REVERSE);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            if (nextProgress.getStatus() != INDEFINITE) {
                applyNextStatus();
            }
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:com.larswerkman.quickreturnlistview.DefaultFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (QuickReturnListView) getListView();

    mQuickReturnView.setText("Default");
    mListView.addHeaderView(mHeader);/*w  w w  . ja  v  a2  s .  c  om*/

    String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android",
            "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };

    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.text1, array));

    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
            mCachedVerticalScrollRange = mListView.getListHeight();
        }
    });

    mListView.setOnScrollListener(new OnScrollListener() {
        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            mScrollY = 0;
            int translationY = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }

            int rawY = mPlaceHolder.getTop()
                    - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollY);

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawY <= mMinRawY) {
                    mMinRawY = rawY;
                } else {
                    mState = STATE_RETURNING;
                }
                translationY = rawY;
                break;

            case STATE_ONSCREEN:
                if (rawY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                translationY = rawY;
                break;

            case STATE_RETURNING:
                translationY = (rawY - mMinRawY) - mQuickReturnHeight;
                if (translationY > 0) {
                    translationY = 0;
                    mMinRawY = rawY - mQuickReturnHeight;
                }

                if (rawY > 0) {
                    mState = STATE_ONSCREEN;
                    translationY = rawY;
                }

                if (translationY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                break;
            }

            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                anim = new TranslateAnimation(0, 0, translationY, translationY);
                anim.setFillAfter(true);
                anim.setDuration(0);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnView.setTranslationY(translationY);
            }

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}

From source file:com.cloverstudio.spikademo.SpikaApp.java

@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    mPreferences = new Preferences(this);
    mPreferences.clearFlagsForTutorialEachBoot(getApplicationContext().getPackageName());
    gOpenFromBackground = true;//from w  ww  . j  a  v a  2  s  . co m
    mFileDir = new FileDir(this);

    ImageLoader.initImageLoaderInstance(this);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create typefaces
    mTfMyriadPro = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    mTfMyriadProBold = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");

    setTransportBasedOnScreenDensity(42);

    // Example interpolator; could use linear or accelerate interpolator
    // instead
    final AccelerateDecelerateInterpolator accDecInterpolator = new AccelerateDecelerateInterpolator();
    final LinearInterpolator linearInterpolator = new LinearInterpolator();
    final int slidingDuration = getResources().getInteger(R.integer.sliding_duration);

    // Set up animations
    mSlideInLeft = new TranslateAnimation(-mTransport, 0, 0, 0);
    mSlideInLeft.setDuration(slidingDuration);
    // mSlideInLeft.setFillAfter(true); // hmm not sure
    mSlideInLeft.setFillEnabled(false);
    mSlideInLeft.setInterpolator(linearInterpolator);

    mSlideOutRight = new TranslateAnimation(0, mTransport, 0, 0);
    mSlideOutRight.setDuration(slidingDuration);
    mSlideOutRight.setFillAfter(true);
    mSlideOutRight.setFillEnabled(true);
    mSlideOutRight.setInterpolator(linearInterpolator);

    mSlideOutLeft = new TranslateAnimation(0, -mTransport, 0, 0);
    mSlideOutLeft.setDuration(slidingDuration);
    mSlideOutLeft.setInterpolator(linearInterpolator);

    mSlideInRight = new TranslateAnimation(mTransport, 0, 0, 0);
    mSlideInRight.setDuration(slidingDuration);
    mSlideInRight.setFillAfter(true);
    mSlideInRight.setFillEnabled(true);
    mSlideInRight.setInterpolator(linearInterpolator);

    mSlideFromTop.setFillAfter(true);
    mSlideFromTop.setFillEnabled(true);
    mSlideFromTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideFromTop.setInterpolator(linearInterpolator);

    mSlideOutTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideOutTop.setInterpolator(linearInterpolator);

    String strUUID = UUID.randomUUID().toString();
    Logger.debug("uuid", strUUID);
}

From source file:com.flan.stock.view.AnimationTabWidget.java

/**
 * ? ?// ww  w.  ja  v a 2  s.  co m
 * @param position
 */
public void setCurrentTab(int position) {

    tv_tag1.setTextSize(12);
    tv_tag2.setTextSize(12);
    tv_tag3.setTextSize(12);
    tv_tag4.setTextSize(12);
    tv_tag5.setTextSize(12);

    tv_tag1.setTextColor(whiteColor);
    tv_tag2.setTextColor(whiteColor);
    tv_tag3.setTextColor(whiteColor);
    tv_tag4.setTextColor(whiteColor);
    tv_tag5.setTextColor(whiteColor);

    switch (position) {
    case 0:
        tv_tag1.setTextColor(redColor);
        tv_tag1.setTextSize(16);
        break;
    case 1:
        tv_tag2.setTextColor(redColor);
        tv_tag2.setTextSize(16);
        break;
    case 2:
        tv_tag3.setTextColor(redColor);
        tv_tag3.setTextSize(16);
        break;
    case 3:
        tv_tag4.setTextColor(redColor);
        tv_tag4.setTextSize(16);
        break;
    case 4:
        tv_tag5.setTextColor(redColor);
        tv_tag5.setTextSize(16);
        break;
    }

    Animation animation = null;
    animation = new TranslateAnimation(imgWidth * currentTab, imgWidth * position, 0, 0);
    animation.setFillAfter(true);//True:???
    animation.setDuration(300); //?
    img_cursor.startAnimation(animation);

    currentTab = position;

}

From source file:com.vaguehope.onosendai.widget.SidebarLayout.java

protected void animateSidebar(final boolean gotoOpen) {
    final View host = getHostView();
    if (host.getAnimation() != null)
        return;/*from  w ww .j a v a2 s  .c o m*/

    final float deltaX;
    final Animation animation;
    if (gotoOpen) {
        deltaX = host.getTranslationX() > 0 ? -host.getTranslationX() : -this.sidebarWidth;
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.openListener);
    } else {
        deltaX = this.sidebarWidth - host.getTranslationX();
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.closeListener);
    }
    animation.setDuration((long) (SLIDE_DURATION * (Math.abs(deltaX) / this.sidebarWidth)));
    animation.setFillAfter(true);
    animation.setFillEnabled(true);
    host.startAnimation(animation);
}

From source file:com.amalbit.BottomFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (PullToRefreshListView) getListView();
    alTweets = new ArrayList<String>();
    for (int i = 0; i < 50; i++)
        alTweets.add("Tweet Number " + i);

    adapter = new ListAdapter();
    mListView.setAdapter(adapter);/*  w ww .ja  v a 2  s .  co m*/
    ((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
        }
    });

    mListView.setOnScrollListener(new OnScrollListener() {
        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            mScrollY = 0;
            int translationY = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }

            int rawY = mScrollY;

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawY >= mMinRawY) {
                    mMinRawY = rawY;
                } else {
                    mState = STATE_RETURNING;
                }
                translationY = rawY;
                break;

            case STATE_ONSCREEN:
                if (rawY > mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                translationY = rawY;
                break;

            case STATE_RETURNING:

                translationY = (rawY - mMinRawY) + mQuickReturnHeight;

                System.out.println(translationY);
                if (translationY < 0) {
                    translationY = 0;
                    mMinRawY = rawY + mQuickReturnHeight;
                }

                if (rawY == 0) {
                    mState = STATE_ONSCREEN;
                    translationY = 0;
                }

                if (translationY > mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                break;
            }

            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                anim = new TranslateAnimation(0, 0, translationY, translationY);
                anim.setFillAfter(true);
                anim.setDuration(0);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnView.setTranslationY(translationY);
            }

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}

From source file:com.marshalchen.common.demoofui.quickreturnlistview.DefaultFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (QuickReturnListView) getListView();

    mQuickReturnView.setText("Default");
    mListView.addHeaderView(mHeader);/*from w w w  .  j a v a  2s .c  om*/

    String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android",
            "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };

    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.quick_return_listview_list_item, R.id.text1,
            array));

    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
            mCachedVerticalScrollRange = mListView.getListHeight();
        }
    });

    mListView.setOnScrollListener(new OnScrollListener() {
        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            mScrollY = 0;
            int translationY = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }

            int rawY = mPlaceHolder.getTop()
                    - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollY);

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawY <= mMinRawY) {
                    mMinRawY = rawY;
                } else {
                    mState = STATE_RETURNING;
                }
                translationY = rawY;
                break;

            case STATE_ONSCREEN:
                if (rawY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                translationY = rawY;
                break;

            case STATE_RETURNING:
                translationY = (rawY - mMinRawY) - mQuickReturnHeight;
                if (translationY > 0) {
                    translationY = 0;
                    mMinRawY = rawY - mQuickReturnHeight;
                }

                if (rawY > 0) {
                    mState = STATE_ONSCREEN;
                    translationY = rawY;
                }

                if (translationY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                break;
            }

            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                anim = new TranslateAnimation(0, 0, translationY, translationY);
                anim.setFillAfter(true);
                anim.setDuration(0);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnView.setTranslationY(translationY);
            }

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}

From source file:com.larswerkman.quickreturnlistview.AnimationFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (QuickReturnListView) getListView();

    mQuickReturnView.setText("Animation");
    mListView.addHeaderView(mHeader);//from   w w  w . j av  a  2 s .  c om

    String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android",
            "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };

    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.text1, array));

    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
            mCachedVerticalScrollRange = mListView.getListHeight();
        }
    });

    mListView.setOnScrollListener(new OnScrollListener() {
        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            mScrollY = 0;
            int translationY = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }

            rawY = mPlaceHolder.getTop()
                    - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollY);

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawY <= mMinRawY) {
                    mMinRawY = rawY;
                } else {
                    mState = STATE_RETURNING;
                }
                translationY = rawY;
                break;

            case STATE_ONSCREEN:
                if (rawY < -mQuickReturnHeight) {
                    System.out.println("test3");
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                translationY = rawY;
                break;

            case STATE_RETURNING:

                if (translationY > 0) {
                    translationY = 0;
                    mMinRawY = rawY - mQuickReturnHeight;
                }

                else if (rawY > 0) {
                    mState = STATE_ONSCREEN;
                    translationY = rawY;
                }

                else if (translationY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;

                } else if (mQuickReturnView.getTranslationY() != 0 && !noAnimation) {
                    noAnimation = true;
                    anim = new TranslateAnimation(0, 0, -mQuickReturnHeight, 0);
                    anim.setFillAfter(true);
                    anim.setDuration(250);
                    mQuickReturnView.startAnimation(anim);
                    anim.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation animation) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            noAnimation = false;
                            mMinRawY = rawY;
                            mState = STATE_EXPANDED;
                        }
                    });
                }
                break;

            case STATE_EXPANDED:
                if (rawY < mMinRawY - 2 && !noAnimation) {
                    noAnimation = true;
                    anim = new TranslateAnimation(0, 0, 0, -mQuickReturnHeight);
                    anim.setFillAfter(true);
                    anim.setDuration(250);
                    anim.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            noAnimation = false;
                            mState = STATE_OFFSCREEN;
                        }
                    });
                    mQuickReturnView.startAnimation(anim);
                } else if (translationY > 0) {
                    translationY = 0;
                    mMinRawY = rawY - mQuickReturnHeight;
                }

                else if (rawY > 0) {
                    mState = STATE_ONSCREEN;
                    translationY = rawY;
                }

                else if (translationY < -mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                } else {
                    mMinRawY = rawY;
                }
            }
            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                anim = new TranslateAnimation(0, 0, translationY, translationY);
                anim.setFillAfter(true);
                anim.setDuration(0);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnView.setTranslationY(translationY);
            }

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}

From source file:com.larswerkman.quickreturnlistview.BottomHeaderFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (QuickReturnListView) getListView();

    //mQuickReturnView.setText("Default");
    //mListView.addHeaderView(mHeader);

    String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android",
            "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };

    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.text1, array));

    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*from www. j a  v  a  2 s  .  c o m*/
        public void onGlobalLayout() {
            mQuickReturnHeightTop = mQuickReturnViewTop.getHeight();
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
            mCachedVerticalScrollRange = mListView.getListHeight();
        }
    });

    mListView.setOnScrollListener(new OnScrollListener() {
        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            int translationYtop = topAnim();
            int translationY = bottonAnim();

            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                animTop = new TranslateAnimation(0, 0, translationYtop, translationYtop);
                animTop.setFillAfter(true);
                animTop.setDuration(0);
                mQuickReturnViewTop.startAnimation(animTop);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnViewTop.setTranslationY(translationYtop);
                mQuickReturnView.setTranslationY(translationY);
            }

        }

        private int topAnim() {
            mScrollYtop = 0;
            int translationYtop = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollYtop = mListView.getComputedScrollY();
            }

            int rawYtop = mPlaceHolder.getTop()
                    - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollYtop);

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawYtop <= mMinRawYtop) {
                    mMinRawYtop = rawYtop;
                } else {
                    mState = STATE_RETURNING;
                }
                translationYtop = rawYtop;
                break;

            case STATE_ONSCREEN:
                if (rawYtop < -mQuickReturnHeightTop) {
                    mState = STATE_OFFSCREEN;
                    mMinRawYtop = rawYtop;
                }
                translationYtop = rawYtop;
                break;

            case STATE_RETURNING:
                translationYtop = (rawYtop - mMinRawYtop) - mQuickReturnHeightTop;
                if (translationYtop > 0) {
                    translationYtop = 0;
                    mMinRawYtop = rawYtop - mQuickReturnHeightTop;
                }

                if (rawYtop > 0) {
                    mState = STATE_ONSCREEN;
                    translationYtop = rawYtop;
                }

                if (translationYtop < -mQuickReturnHeightTop) {
                    mState = STATE_OFFSCREEN;
                    mMinRawYtop = rawYtop;
                }
                break;
            }
            return translationYtop;
        }

        private int bottonAnim() {
            // bottom
            mScrollY = 0;
            int translationY = 0;

            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }

            int rawY = mScrollY;

            switch (mState) {
            case STATE_OFFSCREEN:
                if (rawY >= mMinRawY) {
                    mMinRawY = rawY;
                } else {
                    mState = STATE_RETURNING;
                }
                translationY = rawY;
                break;

            case STATE_ONSCREEN:
                if (rawY > mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                translationY = rawY;
                break;

            case STATE_RETURNING:

                translationY = (rawY - mMinRawY) + mQuickReturnHeight;

                System.out.println(translationY);
                if (translationY < 0) {
                    translationY = 0;
                    mMinRawY = rawY + mQuickReturnHeight;
                }

                if (rawY == 0) {
                    mState = STATE_ONSCREEN;
                    translationY = 0;
                }

                if (translationY > mQuickReturnHeight) {
                    mState = STATE_OFFSCREEN;
                    mMinRawY = rawY;
                }
                break;
            }
            return translationY;
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}