public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
      // This page is way off-screen to the left.
      view.setAlpha(0);

    } else if (position <= 0) { // [-1,0]
      // Use the default slide transition when moving to the left page
      view.setAlpha(1);
      view.setTranslationX(0);
      view.setScaleX(1);
      view.setScaleY(1);

    } else if (position <= 1) { // (0,1]
      // Fade the page out.
      view.setAlpha(1 - position);

      // Counteract the default slide transition
      view.setTranslationX(pageWidth * -position);

      // Scale the page down (between MIN_SCALE and 1)
      float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
      view.setScaleX(scaleFactor);
      view.setScaleY(scaleFactor);

    } else { // (1,+Infinity]
      // This page is way off-screen to the right.
      view.setAlpha(0);
    }
  }
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
      super.onScrolled(recyclerView, dx, dy);

      int childCount = recyclerView.getChildCount();
      int width = recyclerView.getChildAt(0).getWidth();
      int padding = (recyclerView.getWidth() - width) / 2;

      for (int i = 0; i < childCount; i++) {
        View view = recyclerView.getChildAt(i);

        float ratio = 0;

        if (view.getLeft() <= padding) {
          if (view.getLeft() >= padding - view.getWidth()) {
            ratio = (padding - view.getLeft()) * 1f / view.getWidth();
          } else {
            ratio = 1;
          }
          view.setScaleY(1 - ratio * 0.5f);
          view.setScaleX(1 - ratio * 0.5f);

        } else {

          if (view.getLeft() <= recyclerView.getWidth() - padding) {
            ratio = (recyclerView.getWidth() - padding - view.getLeft()) * 1f / view.getWidth();
          }
          view.setScaleY(0.5f + ratio * 0.5f);
          view.setScaleX(0.5f + ratio * 0.5f);
        }
      }
    }
 @Override
 protected void onTransform(View view, float position) {
   if (position <= 0f) {
     view.setTranslationX(0f);
     view.setScaleX(1f);
     view.setScaleY(1f);
   } else if (position <= 1f) {
     final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
     view.setAlpha(1 - position);
     view.setPivotY(0.5f * view.getHeight());
     view.setTranslationX(view.getWidth() * -position);
     view.setScaleX(scaleFactor);
     view.setScaleY(scaleFactor);
   }
 }
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    // 布局卡片view
    int size = viewList.size();
    for (int i = 0; i < size; i++) {
      View viewItem = viewList.get(i);
      int childHeight = viewItem.getMeasuredHeight();
      viewItem.layout(left, top, right, top + childHeight);
      int offset = yOffsetStep * i;
      float scale = 1 - SCALE_STEP * i;
      if (i > 2) {
        // 备用的view
        offset = yOffsetStep * 2;
        scale = 1 - SCALE_STEP * 2;
      }

      viewItem.offsetTopAndBottom(offset);
      viewItem.setScaleX(scale);
      viewItem.setScaleY(scale);
    }

    // 布局底部按钮的View
    if (null != bottomLayout) {
      int layoutTop = viewList.get(0).getMeasuredHeight() + bottomMarginTop;
      bottomLayout.layout(left, layoutTop, right, layoutTop + bottomLayout.getMeasuredHeight());
    }

    // 初始化一些中间参数
    initCenterViewX = viewList.get(0).getLeft();
    initCenterViewY = viewList.get(0).getTop();
    childWith = viewList.get(0).getMeasuredWidth();
  }
Exemplo n.º 5
0
 public void setScaleX(float scaleX) {
   if (NEEDS_PROXY) {
     wrap(this).setScaleX(scaleX);
   } else {
     super.setScaleX(scaleX);
   }
 }
  public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
      // This page is way off-screen to the left.
      view.setAlpha(0);

    } else if (position <= 1) { // [-1,1]
      // Modify the default slide transition to shrink the page as well
      float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
      float vertMargin = pageHeight * (1 - scaleFactor) / 2;
      float horzMargin = pageWidth * (1 - scaleFactor) / 2;
      if (position < 0) {
        view.setTranslationX(horzMargin - vertMargin / 2);
      } else {
        view.setTranslationX(-horzMargin + vertMargin / 2);
      }

      // Scale the page down (between MIN_SCALE and 1)
      view.setScaleX(scaleFactor);
      view.setScaleY(scaleFactor);

      // Fade the page relative to its size.
      view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
      // This page is way off-screen to the right.
      view.setAlpha(0);
    }
  }
Exemplo n.º 7
0
  @Override
  public void transformPage(View view, float position) {

    if (-INITIAL_POSITION <= position && position <= FINAL_POSITION) {
      if (position <= MEDIUM_POSITION) {
        view.setScaleX(position / INCLINE_FACTOR + MOVE_FACTOR_LEFT);
        view.setScaleY(position / INCLINE_FACTOR + MOVE_FACTOR_LEFT);
      } else {
        view.setScaleX(-position / INCLINE_FACTOR + MOVE_FACTOR_RIGHT);
        view.setScaleY(-position / INCLINE_FACTOR + MOVE_FACTOR_RIGHT);
      }
    } else {
      view.setScaleX(SCALE_MIN_FACTOR);
      view.setScaleY(SCALE_MIN_FACTOR);
    }
  }
 private void showFooterLoadingView() {
   View view = mFooterLoadingView.findViewById(R.id.pb_loding);
   view.setVisibility(View.VISIBLE);
   view.setScaleX(1.0f);
   view.setScaleY(1.0f);
   view.setAlpha(1.0f);
   mFooterLoadingView.findViewById(R.id.tv_load_failed).setVisibility(View.GONE);
 }
 @Override
 protected void onTransform(View view, float position) {
   view.setPivotX(position < 0 ? 0 : view.getWidth());
   view.setPivotY(view.getHeight() / 2f);
   float scale = position < 0 ? 1f + position : 1f - position;
   view.setScaleX(scale);
   view.setScaleY(scale);
 }
 @Override
 private void start(View view, long l, float f, float f2, float f3, float f4, float f5, float f6) {
   view.setScaleX(f);
   view.setScaleY(f);
   view.setTranslationX(f3);
   view.setTranslationY(f4);
   ViewPropertyAnimator viewPropertyAnimator =
       view.animate().translationX(f5).translationY(f6).scaleX(f2).scaleY(f2).setDuration(l);
   viewPropertyAnimator.start();
 }
Exemplo n.º 11
0
 /** Resets this view's properties */
 void resetViewProperties() {
   setDim(0);
   setLayerType(View.LAYER_TYPE_NONE, null);
   TaskViewTransform.reset(this);
   if (mActionButtonView != null) {
     mActionButtonView.setScaleX(1f);
     mActionButtonView.setScaleY(1f);
     mActionButtonView.setAlpha(1f);
     mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
   }
 }
Exemplo n.º 12
0
 /** apply selected in view */
 public static void applyScaleX(View view, DynamicProperty property) {
   if (view != null) {
     switch (property.type) {
       case BOOLEAN:
         {
           view.setScaleX(property.getValueFloat());
         }
         break;
     }
   }
 }
Exemplo n.º 13
0
 /**
  * reset the view to default status
  *
  * @param target the target
  */
 public void reset(View target) {
   target.setAlpha(1);
   target.setScaleX(1);
   target.setScaleY(1);
   target.setTranslationX(0);
   target.setTranslationY(0);
   target.setRotation(0);
   target.setRotationY(0);
   target.setRotationX(0);
   target.setPivotX(target.getMeasuredWidth() / 2.0f);
   target.setPivotY(target.getMeasuredHeight() / 2.0f);
 }
Exemplo n.º 14
0
 // Debemos recordar que la traslationX ya se realiza por defecto.
 @Override
 public void transformPage(View view, float position) {
   // Si la página no está visible se resetean los valores por defecto.
   if (position <= -1 || position >= 1) {
     view.setScaleX(1);
     view.setScaleY(1);
   } else {
     // Si se trata del panel de la derecha (0, 1)
     if (position > 0) {
       // Se escala como hasta como máximo la mitad de su tamaño.
       view.setScaleX(Math.max(ESCALA_MINIMA, (1 - position)));
       view.setScaleY(Math.max(ESCALA_MINIMA, (1 - position)));
     }
     // Si se trata del panel de la izquierda o visible entero (-1, 0]
     else {
       // Se escala como hasta como máximo la mitad de su tamaño.
       view.setScaleX(Math.max(ESCALA_MINIMA, (1 + position)));
       view.setScaleY(Math.max(ESCALA_MINIMA, (1 + position)));
     }
   }
 }
Exemplo n.º 15
0
 private void reset(View root) {
   if (root instanceof ViewGroup) {
     ViewGroup parent = (ViewGroup) root;
     for (int i = 0; i < parent.getChildCount(); i++) {
       reset(parent.getChildAt(i));
     }
   } else {
     root.setScaleX(1);
     root.setScaleY(1);
     root.setAlpha(1);
   }
 }
  @Override
  protected void onTransform(View view, float position) {
    final float height = view.getHeight();
    final float width = view.getWidth();
    final float scale = min(position < 0 ? 1f : Math.abs(1f - position), 0.5f);

    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(width * 0.5f);
    view.setPivotY(height * 0.5f);
    view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
  }
Exemplo n.º 17
0
 /**
  * 拡大・縮小を行います。
  *
  * @param newScale 設定する拡大率
  */
 private void setScale(float newScale) {
   // INFO:childにscaleを設定しないと拡大率が変わらない現象に対処するための修正
   if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
     final int childCount = getChildCount();
     for (int i = 0; i < childCount; i++) {
       final View targetView = getChildAt(i);
       targetView.setScaleX(newScale);
       targetView.setScaleY(newScale);
     }
   } else {
     setScaleX(newScale);
     setScaleY(newScale);
   }
 }
  private void interpolate(View view1, View view2, float interpolation) {
    getOnScreenRect(mRect1, view1);
    getOnScreenRect(mRect2, view2);

    float scaleX = 1.0F + interpolation * (mRect2.width() / mRect1.width() - 1.0F);
    float scaleY = 1.0F + interpolation * (mRect2.height() / mRect1.height() - 1.0F);
    float translationX =
        0.5F * (interpolation * (mRect2.left + mRect2.right - mRect1.left - mRect1.right));
    float translationY =
        0.5F * (interpolation * (mRect2.top + mRect2.bottom - mRect1.top - mRect1.bottom));

    view1.setTranslationX(translationX);
    view1.setTranslationY(translationY - mHeader.getTranslationY());
    view1.setScaleX(scaleX);
    view1.setScaleY(scaleY);
  }
Exemplo n.º 19
0
  private void animateButton(View loginButton) {
    loginButton.setScaleX(0f);
    loginButton.setScaleY(0f);
    loginButton.setAlpha(0f);

    ObjectAnimator animator1 = ObjectAnimator.ofFloat(loginButton, "alpha", 1f);
    animator1.setDuration(1000);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(loginButton, "scaleX", 1f);
    animator2.setDuration(1000);
    ObjectAnimator animator3 = ObjectAnimator.ofFloat(loginButton, "scaleY", 1f);
    animator3.setDuration(1000);

    AnimatorSet set = new AnimatorSet();
    set.play(animator1).with(animator2).with(animator3);
    set.start();
  }
  // 由index对应view变成index-1对应的view
  private void ajustLinkageViewItem(View changedView, float rate, int index) {
    int changeIndex = viewList.indexOf(changedView);
    int initPosY = yOffsetStep * index;
    float initScale = 1 - SCALE_STEP * index;

    int nextPosY = yOffsetStep * (index - 1);
    float nextScale = 1 - SCALE_STEP * (index - 1);

    int offset = (int) (initPosY + (nextPosY - initPosY) * rate);
    float scale = initScale + (nextScale - initScale) * rate;

    View ajustView = viewList.get(changeIndex + index);
    ajustView.offsetTopAndBottom(offset - ajustView.getTop() + initCenterViewY);
    ajustView.setScaleX(scale);
    ajustView.setScaleY(scale);
  }
Exemplo n.º 21
0
  private void animateLogo(View vkLogo) {
    vkLogo.setScaleX(0f);
    vkLogo.setScaleY(0f);
    vkLogo.setAlpha(0f);

    ObjectAnimator animator1 = ObjectAnimator.ofFloat(vkLogo, "rotation", 720f);
    animator1.setDuration(1000);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(vkLogo, "alpha", 1f);
    animator2.setDuration(1000);
    ObjectAnimator animator3 = ObjectAnimator.ofFloat(vkLogo, "scaleX", 1f);
    animator3.setDuration(1000);
    ObjectAnimator animator4 = ObjectAnimator.ofFloat(vkLogo, "scaleY", 1f);
    animator4.setDuration(1000);

    AnimatorSet set = new AnimatorSet();
    set.play(animator1).with(animator2).with(animator3).with(animator4);
    set.start();
  }
Exemplo n.º 22
0
  private Animator createShowItemAnimator(View item) {
    float dx = centerItem.getX() - item.getX();
    float dy = centerItem.getY() - item.getY();

    item.setScaleX(0f);
    item.setScaleY(0f);
    item.setTranslationX(dx);
    item.setTranslationY(dy);

    Animator anim =
        ObjectAnimator.ofPropertyValuesHolder(
            item,
            AnimatorUtils.scaleX(0f, 1f),
            AnimatorUtils.scaleY(0f, 1f),
            AnimatorUtils.translationX(dx, 0f),
            AnimatorUtils.translationY(dy, 0f));

    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(50);
    return anim;
  }
Exemplo n.º 23
0
 // 设置动画效果代码
 public void setStyleCode(int type) {
   try {
     mType = type;
     char[] ints = (mType + "").toCharArray();
     mTransInt = ints[0] - '0';
     mScaleInt = ints[1] - '0';
     mAlphaInt = ints[2] - '0';
     mRotateInt = ints[3] - '0';
     mMenuView = getChildAt(0);
     if (mMenuView != null) {
       mMenuView.setScaleX(1);
       mMenuView.setScaleY(1);
       mMenuView.setTranslationX(0);
       mMenuView.setRotationX(0);
       mMenuView.setRotationY(0);
       mMenuView.setRotationX(0);
       mMenuView.setAlpha(1);
     }
   } catch (Exception e) {
     Log.e("SwipeMenu", "动画代码设置出错,请检查范围");
   }
 }
Exemplo n.º 24
0
 private void start(
     View view,
     long duration,
     float fromScale,
     float toScale,
     float fromTranslationX,
     float fromTranslationY,
     float toTranslationX,
     float toTranslationY) {
   view.setScaleX(fromScale);
   view.setScaleY(fromScale);
   view.setTranslationX(fromTranslationX);
   view.setTranslationY(fromTranslationY);
   ViewPropertyAnimator propertyAnimator =
       view.animate()
           .translationX(toTranslationX)
           .translationY(toTranslationY)
           .scaleX(toScale)
           .scaleY(toScale)
           .setDuration(duration);
   propertyAnimator.start();
   DebugUtils.log("KenBurnsView: starting Ken Burns animation " + propertyAnimator);
 }
Exemplo n.º 25
0
 public static void setScaleX(View view, float f) {
   view.setScaleX(f);
 }
Exemplo n.º 26
0
  public synchronized void place(View v, Point pt, boolean animate) {
    final int i = pt.x;
    final int j = pt.y;
    final float rnd = frand();
    if (v.getTag(TAG_POS) != null) {
      for (final Point oc : getOccupied(v)) {
        mFreeList.add(oc);
        mCells[oc.y * mColumns + oc.x] = null;
      }
    }
    int scale = 1;
    if (rnd < PROB_4X) {
      if (!(i >= mColumns - 3 || j >= mRows - 3)) {
        scale = 4;
      }
    } else if (rnd < PROB_3X) {
      if (!(i >= mColumns - 2 || j >= mRows - 2)) {
        scale = 3;
      }
    } else if (rnd < PROB_2X) {
      if (!(i == mColumns - 1 || j == mRows - 1)) {
        scale = 2;
      }
    }

    v.setTag(TAG_POS, pt);
    v.setTag(TAG_SPAN, scale);

    tmpSet.clear();

    final Point[] occupied = getOccupied(v);
    for (final Point oc : occupied) {
      final View squatter = mCells[oc.y * mColumns + oc.x];
      if (squatter != null) {
        tmpSet.add(squatter);
      }
    }

    for (final View squatter : tmpSet) {
      for (final Point sq : getOccupied(squatter)) {
        mFreeList.add(sq);
        mCells[sq.y * mColumns + sq.x] = null;
      }
      if (squatter != v) {
        squatter.setTag(TAG_POS, null);
        if (animate) {
          squatter
              .animate()
              .withLayer()
              .scaleX(0.5f)
              .scaleY(0.5f)
              .alpha(0)
              .setDuration(DURATION)
              .setInterpolator(new AccelerateInterpolator())
              .setListener(
                  new Animator.AnimatorListener() {
                    public void onAnimationStart(Animator animator) {}

                    public void onAnimationEnd(Animator animator) {
                      removeView(squatter);
                    }

                    public void onAnimationCancel(Animator animator) {}

                    public void onAnimationRepeat(Animator animator) {}
                  })
              .start();
        } else {
          removeView(squatter);
        }
      }
    }

    for (final Point oc : occupied) {
      mCells[oc.y * mColumns + oc.x] = v;
      mFreeList.remove(oc);
    }

    final float rot = (float) irand(0, 4) * 90f;

    if (animate) {
      v.bringToFront();

      AnimatorSet set1 = new AnimatorSet();
      set1.playTogether(
          ObjectAnimator.ofFloat(v, View.SCALE_X, (float) scale),
          ObjectAnimator.ofFloat(v, View.SCALE_Y, (float) scale));
      set1.setInterpolator(new AnticipateOvershootInterpolator());
      set1.setDuration(DURATION);

      AnimatorSet set2 = new AnimatorSet();
      set2.playTogether(
          ObjectAnimator.ofFloat(v, View.ROTATION, rot),
          ObjectAnimator.ofFloat(v, View.X, i * mCellSize + (scale - 1) * mCellSize / 2),
          ObjectAnimator.ofFloat(v, View.Y, j * mCellSize + (scale - 1) * mCellSize / 2));
      set2.setInterpolator(new DecelerateInterpolator());
      set2.setDuration(DURATION);

      set1.addListener(makeHardwareLayerListener(v));

      set1.start();
      set2.start();
    } else {
      v.setX(i * mCellSize + (scale - 1) * mCellSize / 2);
      v.setY(j * mCellSize + (scale - 1) * mCellSize / 2);
      v.setScaleX((float) scale);
      v.setScaleY((float) scale);
      v.setRotation(rot);
    }
  }
 @Override
 protected void onTransform(View view, float position) {
   view.setPivotX(position < 0 ? 0 : view.getWidth());
   view.setScaleX(position < 0 ? 1f + position : 1f - position);
 }
Exemplo n.º 28
0
  // Show(or hide) one view with some effects
  private void showView(int viewId, int delay, int b) {
    View myView = findViewById(viewId);
    final int behavior = b;

    if (android.os.Build.VERSION.SDK_INT >= 21) {

      float x = myView.getX();
      float y = myView.getY();

      Path path1 = new Path();
      Path path2 = new Path();

      // Show with bounce effect
      if (behavior == 0) {
        path1.moveTo(x, y + 100);
        path1.rLineTo(0, -100);
        path2.moveTo(0, 0);
        path2.lineTo(1, 1);
      }
      // Show with bounce effect(and drop from top)
      else if (behavior == 1) {
        path1.moveTo(x, y - 300);
        path1.rLineTo(0, 300);
        path2.moveTo(1, 1);
        path2.lineTo(1, 1);
      }
      // Show with inflate effect
      else if (behavior == 2) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(1, 1);
        path2.lineTo(10, 10);
      }
      // Hide with deflate effect(from large shape)
      else if (behavior == 3) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(10, 10);
        path2.lineTo(1, 1);
      }
      // Fade in and float
      else if (behavior == 4) {
        path1.moveTo(x, y + 50);
        path1.rLineTo(0, -50);
        path2.moveTo(1, 1);
        path2.lineTo(1, 1);
      }
      // Fade out
      else if (behavior == 5) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(1, 1);
        path2.lineTo(1, 1);
      }
      // Hide with deflate effect
      else if (behavior == 6) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(1, 1);
        path2.lineTo(0, 0);
      }
      // Show with inflate effect
      else if (behavior == 7) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(1, 1);
        path2.lineTo(20, 20);
      }
      // Hide with deflate effect(from large shape)
      else if (behavior == 8) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(20, 20);
        path2.lineTo(1, 1);
      }
      // This effect only used for the flipTimes label
      else if (behavior == 9) {
        path1.moveTo(x, y);
        path1.rLineTo(0, 0);
        path2.moveTo(1, 1);
        path2.lineTo(1, 1);
        path2.lineTo(2, 2);
      }

      ObjectAnimator mAnimator1, mAnimator2, mAnimator3;
      mAnimator1 = ObjectAnimator.ofFloat(myView, View.X, View.Y, path1);
      mAnimator2 = ObjectAnimator.ofFloat(myView, View.SCALE_X, View.SCALE_Y, path2);
      mAnimator1.setDuration(300);
      mAnimator2.setDuration(300);
      mAnimator1.setStartDelay(delay);
      mAnimator2.setStartDelay(delay);

      if (behavior == 0 || behavior == 1) {
        mAnimator1.setInterpolator(new BounceInterpolator());
        mAnimator2.setInterpolator(new BounceInterpolator());
        mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 1);
        mAnimator3.setDuration(10);
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
      } else if (behavior == 2 || behavior == 7) {
        myView.bringToFront();
        FrameLayout menuLayout = (FrameLayout) findViewById(R.id.menu);
        menuLayout.requestLayout();
        menuLayout.invalidate();

        mAnimator3 =
            ObjectAnimator.ofArgb(
                myView, "textColor", ((Button) myView).getCurrentTextColor(), Color.TRANSPARENT);
        mAnimator3.setDuration(100);
        mAnimator1.setInterpolator(new AccelerateInterpolator());
        mAnimator2.setInterpolator(new AccelerateInterpolator());
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
        mSound.play(mSoundID[SOUND_OPEN], 1, 1, 1, 0, 1);
      } else if (behavior == 3 || behavior == 8) {
        mAnimator3 =
            ObjectAnimator.ofArgb(
                myView, "textColor", ((Button) myView).getCurrentTextColor(), Color.WHITE);
        mAnimator3.setDuration(100);
        mAnimator1.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setInterpolator(new DecelerateInterpolator());
        mAnimator3.setStartDelay(delay + 200);
        mAnimator3.start();
        mSound.play(mSoundID[SOUND_CLOSE], 1, 1, 1, 0, 1);
      } else if (behavior == 4) {
        mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 1);
        mAnimator3.setDuration(300);
        mAnimator1.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setInterpolator(new DecelerateInterpolator());
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
      } else if (behavior == 5) {
        mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 0);
        mAnimator3.setDuration(300);
        mAnimator1.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setInterpolator(new DecelerateInterpolator());
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
      } else if (behavior == 6) {
        mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 0);
        mAnimator3.setDuration(300);
        mAnimator1.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setInterpolator(new DecelerateInterpolator());
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
      } else if (behavior == 9) {
        mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", 1, 0);
        mAnimator2.setDuration(1000);
        mAnimator3.setDuration(1000);
        mAnimator1.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setInterpolator(new DecelerateInterpolator());
        mAnimator2.setRepeatCount(Animation.INFINITE);
        mAnimator3.setRepeatCount(Animation.INFINITE);
        mAnimator3.setStartDelay(delay);
        mAnimator3.start();
      }
      if (behavior == 0 || behavior == 1 || behavior == 4) {
        mAnimator1.start();
      }
      mAnimator2.start();

      mAnimator1.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
              if (behavior == 0) {
                mSound.play(mSoundID[SOUND_BLOP], 1, 1, 1, 0, 1);
              }
            }

            @Override
            public void onAnimationEnd(Animator animation) {}

            @Override
            public void onAnimationCancel(Animator animation) {}

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
    }
    // If the device OS is below Lollipop, the animation feature will be lost
    else {
      if (behavior == 5 || behavior == 6) {
        myView.setAlpha(0);
      } else {
        myView.setAlpha(1);
      }

      if (behavior == 2) {
        myView.setScaleX(10);
        myView.setScaleY(10);
        ((Button) myView).setTextColor(Color.TRANSPARENT);
      } else if (behavior == 3) {
        myView.setScaleX(1);
        myView.setScaleY(1);
        ((Button) myView).setTextColor(Color.WHITE);
      }

      if (behavior == 0) {
        mSound.play(mSoundID[SOUND_BLOP], 1, 1, 1, 0, 1);
      } else if (behavior == 2 || behavior == 7) {
        mSound.play(mSoundID[SOUND_OPEN], 1, 1, 1, 0, 1);
      } else if (behavior == 3 || behavior == 8) {
        mSound.play(mSoundID[SOUND_CLOSE], 1, 1, 1, 0, 1);
      } else if (behavior == 6) {
        mSound.play(mSoundID[SOUND_CLICK], 1, 1, 1, 0, 1);
      }
    }
  }
Exemplo n.º 29
0
 static void setScaleX(View view, float scaleX) {
   view.setScaleX(scaleX);
 }
 public void zoom(Float scaleX, Float scaleY, PointF pivot) {
   transformableView.setPivotX(pivot.x);
   transformableView.setPivotY(pivot.y);
   transformableView.setScaleX(scaleX);
   transformableView.setScaleY(scaleY);
 }