// if sdk < 14, just ignore because of min sdk is 14
  private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
      int translationY = button.getHeight() + getMarginBottom(button);
      ViewCompat.animate(button)
          .scaleX(0.0F)
          .scaleY(0.0F)
          .alpha(0.0F)
          .translationY(translationY)
          .setInterpolator(INTERPOLATOR)
          .withLayer()
          .setListener(
              new ViewPropertyAnimatorListener() {
                public void onAnimationStart(View view) {
                  BetterFabBehavior.this.mIsAnimatingOut = true;
                }

                public void onAnimationCancel(View view) {
                  BetterFabBehavior.this.mIsAnimatingOut = false;
                }

                public void onAnimationEnd(View view) {
                  BetterFabBehavior.this.mIsAnimatingOut = false;
                  view.setVisibility(View.GONE);
                }
              })
          .start();
    }
  }
 private void hideViews() {
   RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) searchButton.getLayoutParams();
   int fabBottomMargin = lp.bottomMargin;
   searchButton
       .animate()
       .translationY(searchButton.getHeight() + fabBottomMargin)
       .setInterpolator(new AccelerateInterpolator(2))
       .start();
 }
  /**
   * Sets up the height / position of the fab and tray
   *
   * <p>Returns true if it requires a relayout
   */
  protected void initializeLayout() {
    CalculatorPadLayout layout = (CalculatorPadLayout) findViewById(R.id.pad_advanced);
    int rows = layout.getRows();
    int columns = layout.getColumns();

    View parent = (View) mFab.getParent();
    mFab.setTranslationX((mFab.getWidth() - parent.getWidth() / columns) / 2);
    mFab.setTranslationY((mFab.getHeight() - parent.getHeight() / rows) / 2);
  }
  @Override
  public void onDetach() {
    button.setClickable(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Animator anim =
          ViewAnimationUtils.createCircularReveal(
                  thirdView,
                  thirdView.getWidth() / 2,
                  thirdView.getHeight() / 2,
                  0,
                  thirdView.getHeight())
              .setDuration(450);

      thirdView.setVisibility(View.VISIBLE);
      anim.start();
    } else {
      thirdView.setVisibility(View.VISIBLE);
    }

    super.onDetach();
  }
 @Override
 public boolean onDependentViewChanged(
     CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
   boolean returnValue = super.onDependentViewChanged(parent, fab, dependency);
   if (dependency instanceof AppBarLayout) {
     CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
     int fabBottomMargin = lp.bottomMargin;
     int distanceToScroll = fab.getHeight() + fabBottomMargin;
     float ratio = (float) dependency.getY() / (float) toolbarHeight;
     fab.setTranslationY(-distanceToScroll * ratio);
   }
   return returnValue;
 }
Example #6
0
  private void startRipple() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      final CoordinatorLayout coordinatorLayout =
          (CoordinatorLayout) findViewById(R.id.coordinator_layout);
      Drawable d = coordinatorLayout.getBackground();
      final RippleDrawable rippleDrawable = (RippleDrawable) d;
      rippleDrawable.setHotspot(
          mReset.getX() + mReset.getWidth() / 2, mReset.getY() + mReset.getHeight() / 2);
      rippleDrawable.setState(
          new int[] {android.R.attr.state_pressed, android.R.attr.state_enabled});
      coordinatorLayout.getBackground().setState(new int[] {});
    }

    mReset.hide();
    mElapsedTime = 0;
    setTime();
  }
 @Override
 public boolean onDependentViewChanged(
     CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
   if (dependency instanceof AppBarLayout) {
     AppBarLayout appBarLayout = (AppBarLayout) dependency;
     CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
     int bottomMargin = lp.bottomMargin;
     int distanceToScroll = fab.getHeight() + bottomMargin;
     //            Log.e("@@!!", ViewCompat.getY(appBarLayout) + "\t" +
     // appBarLayout.getTotalScrollRange());
     float ratio = ViewCompat.getY(appBarLayout) / (float) appBarLayout.getTotalScrollRange();
     if (ratio < -0.9f) {
       ratio = -1f;
     }
     ViewCompat.setTranslationY(fab, -distanceToScroll * ratio);
     return true;
   }
   return false;
 }