コード例 #1
0
  public void prepareTabsAnimation(PropertyAnimator animator) {
    // Not worth doing this on pre-Honeycomb without proper
    // hardware accelerated animations.
    if (Build.VERSION.SDK_INT < 11) {
      return;
    }

    if (mIsSideBar) {
      final int tabsPanelWidth = getWidth();
      if (mVisible) {
        ViewHelper.setTranslationX(mHeader, -tabsPanelWidth);
        ViewHelper.setTranslationX(mTabsContainer, -tabsPanelWidth);
        // The footer view is only present on the sidebar
        ViewHelper.setTranslationX(mFooter, -tabsPanelWidth);
      }
      final int translationX = (mVisible ? 0 : -tabsPanelWidth);
      animator.attach(mTabsContainer, PropertyAnimator.Property.TRANSLATION_X, translationX);
      animator.attach(mHeader, PropertyAnimator.Property.TRANSLATION_X, translationX);
      animator.attach(mFooter, PropertyAnimator.Property.TRANSLATION_X, translationX);

    } else if (!mHeaderVisible) {
      final Resources resources = getContext().getResources();
      final int toolbarHeight = resources.getDimensionPixelSize(R.dimen.browser_toolbar_height);
      final int translationY = (mVisible ? 0 : -toolbarHeight);
      animator.attach(mTabsContainer, PropertyAnimator.Property.ALPHA, 1.0f);
      animator.attach(mTabsContainer, PropertyAnimator.Property.TRANSLATION_Y, translationY);
      animator.attach(mHeader, PropertyAnimator.Property.TRANSLATION_Y, translationY);
    }

    mHeader.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mTabsContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
  }
コード例 #2
0
  public void finishTabsAnimation() {
    if (Build.VERSION.SDK_INT < 11) {
      return;
    }

    mHeader.setLayerType(View.LAYER_TYPE_NONE, null);
    mTabsContainer.setLayerType(View.LAYER_TYPE_NONE, null);

    // If the tray is now hidden, call hide() on current panel and unset it as the current panel
    // to avoid hide() being called again when the tray is opened next.
    if (!mVisible && mPanel != null) {
      mPanel.hide();
      mPanel = null;
    }
  }