/** Animation for the textview if the action bar is visible. */ public void startShowAnimation() { if (mCurrentAnimation != null) mCurrentAnimation.cancel(); mCurrentAnimation = ObjectAnimator.ofInt( mActionBarDelegate, TOP_MARGIN_ANIM_PROPERTY, (int) (Math.max(0, queryCurrentActionBarHeight() - mTabStripHeight))) .setDuration(SLIDE_DURATION_MS); mCurrentAnimation.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimation = null; } }); mCurrentAnimation.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { ActionBar actionBar = mActionBarDelegate.getSupportActionBar(); if (actionBar != null) { animation.setIntValues( (int) (Math.max(0, queryCurrentActionBarHeight() - mTabStripHeight))); } } }); mActionBarDelegate.setActionBarBackgroundVisibility(true); mCurrentAnimation.start(); mShowingActionMode = true; }
/** @return The current action bar height. */ private int queryCurrentActionBarHeight() { ActionBar actionBar = mActionBarDelegate.getSupportActionBar(); if (actionBar != null) return actionBar.getHeight(); TypedArray styledAttributes = mContext.obtainStyledAttributes(new int[] {R.attr.actionBarSize}); int height = styledAttributes.getDimensionPixelSize(0, 0); styledAttributes.recycle(); return height; }
@Override public void set(ActionBarDelegate delegate, Integer value) { delegate.setControlTopMargin(value); }
@Override public Integer get(ActionBarDelegate delegate) { return delegate.getControlTopMargin(); }