void startAnimating(final boolean holdAfter) { mAnimating = true; final Animation trans1; final Animation trans2; final Slider slider = mCurrentSlider; final Slider other = mOtherSlider; final int dx; final int dy; if (isHorizontal()) { int right = slider.tab.getRight(); int width = slider.tab.getWidth(); int left = slider.tab.getLeft(); int viewWidth = getWidth(); int holdOffset = holdAfter ? 0 : width; // how much of tab to show at the end of anim dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset; dy = 0; } else { int top = slider.tab.getTop(); int bottom = slider.tab.getBottom(); int height = slider.tab.getHeight(); int viewHeight = getHeight(); int holdOffset = holdAfter ? 0 : height; // how much of tab to show at end of anim dx = 0; dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset); } trans1 = new TranslateAnimation(0, dx, 0, dy); trans1.setDuration(ANIM_DURATION); trans1.setInterpolator(new LinearInterpolator()); trans1.setFillAfter(true); trans2 = new TranslateAnimation(0, dx, 0, dy); trans2.setDuration(ANIM_DURATION); trans2.setInterpolator(new LinearInterpolator()); trans2.setFillAfter(true); trans1.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { Animation anim; if (holdAfter) { anim = new TranslateAnimation(dx, dx, dy, dy); anim.setDuration(1000); // plenty of time for transitions mAnimating = false; } else { anim = new AlphaAnimation(0.5f, 1.0f); anim.setDuration(ANIM_DURATION); resetView(); } anim.setAnimationListener(mAnimationDoneListener); /* Animation can be the same for these since the animation just holds */ mLeftSlider.startAnimation(anim, anim); mRightSlider.startAnimation(anim, anim); } public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) {} }); slider.hideTarget(); slider.startAnimation(trans1, trans2); }