private void animationThree() { controlByFloat.setVisibility(View.VISIBLE); controlByNotify.setVisibility(View.VISIBLE); triggerByFloat.setVisibility(View.VISIBLE); confirmSetting.setVisibility(View.VISIBLE); controlByFloat.setScaleX(0.5f); controlByFloat.setScaleY(0.5f); controlByNotify.setScaleX(0.5f); controlByNotify.setScaleY(0.5f); triggerByFloat.setScaleX(0.5f); triggerByFloat.setScaleY(0.5f); confirmSetting.setScaleX(0.5f); confirmSetting.setScaleY(0.5f); controlByFloat.animate().scaleX(1).scaleY(1).setDuration(500).setInterpolator(new AnticipateOvershootInterpolator()).start(); controlByNotify.animate().scaleX(1).scaleY(1).setDuration(500).setInterpolator(new AnticipateOvershootInterpolator()).start(); triggerByFloat.animate().scaleX(1).scaleY(1).setDuration(500).setInterpolator(new AnticipateOvershootInterpolator()).start(); confirmSetting.animate().scaleX(1).scaleY(1).setDuration(500).setInterpolator(new AnticipateOvershootInterpolator()).start(); }
private void initInterpolations() { ArrayList<Class> interpolatorList = new ArrayList<Class>() {{ add(FastOutSlowInInterpolator.class); add(BounceInterpolator.class); add(LinearInterpolator.class); add(DecelerateInterpolator.class); add(CycleInterpolator.class); add(AnticipateInterpolator.class); add(AccelerateDecelerateInterpolator.class); add(AccelerateInterpolator.class); add(AnticipateOvershootInterpolator.class); add(FastOutLinearInInterpolator.class); add(LinearOutSlowInInterpolator.class); add(OvershootInterpolator.class); }}; try { interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance(); } catch (Exception e) { e.printStackTrace(); } }
/** * 重置第一张卡片 */ private void makeFirstViewReset() { CardView firstSlideView = getFirstSlideView(); firstSlideView.resetRotateType(); float rotate = firstSlideView.getCardRotation(); int startX = firstSlideView.getScrollX(); int startY = firstSlideView.getScrollY(); ValueAnimator animator = ValueAnimator.ofFloat(1, 0); animator.setTarget(firstSlideView); animator.setDuration(ANIM_DURATION); animator.setInterpolator(new AnticipateOvershootInterpolator()); animator.addUpdateListener((animation) -> { float curRate = (float) animation.getAnimatedValue(); firstSlideView.scrollTo((int) (startX * curRate), (int) (startY * curRate)); firstSlideView.setReleaseRotation(curRate * rotate); }); animator.start(); }
/** * 第一张卡片滑出时,剩余卡片上浮 * @param position */ private void makeUnderViewReplace(int position) { CardView underSlideView = slideViewMap.get(position); if (underSlideView != null) { ValueAnimator animator = ValueAnimator.ofFloat(percent, 1); animator.setTarget(underSlideView); animator.setDuration(ANIM_DURATION); animator.setInterpolator(new AnticipateOvershootInterpolator()); animator.addUpdateListener(animation -> { float curPercent = (float) animation.getAnimatedValue(); makeUnderViewInvalidate(position, curPercent); }); animator.start(); } }
private void hideInitialCallToAction() { animatorFor(generateData, getAnimatorContext()) .withInterpolator(new AnticipateOvershootInterpolator()) .alpha(0f) .scale(0f) .addOnAnimationCompleted(new OnAnimationCompleted() { @Override public void onAnimationCompleted(boolean finished) { if (finished) { generateData.setVisibility(View.INVISIBLE); generateData.setScaleX(1f); generateData.setScaleY(1f); generateData.setAlpha(1f); } } }) .start(); }
private void showGenerateData() { animatorFor(generateData, getAnimatorContext()) .withInterpolator(new AnticipateOvershootInterpolator()) .addOnAnimationWillStart(new MultiAnimator.WillRunListener() { @Override public void onMultiAnimatorWillRun(@NonNull MultiAnimator animator) { generateData.setAlpha(0f); generateData.setScaleX(0f); generateData.setScaleY(0f); generateData.setVisibility(View.VISIBLE); } }) .alpha(1f) .scale(1f) .start(); }
public void fillResourceAttributes(AnticipateOvershootInterpolator interpolator, DOMElement domElement, AttrInterpolatorContext attrCtx) { XMLInflaterResource xmlInflaterInterpolator = attrCtx.getXMLInflaterResource(); XMLInflaterRegistry xmlInflaterRegistry = xmlInflaterInterpolator.getInflatedXMLResource().getXMLInflaterRegistry(); DOMAttr attrTension = domElement.getDOMAttribute(NamespaceUtil.XMLNS_ANDROID, "tension"); float tension = attrTension != null ? xmlInflaterRegistry.getFloat(attrTension.getResourceDesc(),attrCtx.getXMLInflaterContext()) : 2.0f; DOMAttr attrExtraTension = domElement.getDOMAttribute(NamespaceUtil.XMLNS_ANDROID, "extraTension"); float extraTension = attrExtraTension != null ? xmlInflaterRegistry.getFloat(attrExtraTension.getResourceDesc(),attrCtx.getXMLInflaterContext()) : 1.5f; float totalTension = tension * extraTension; fieldMTension.set(interpolator,totalTension); super.fillResourceAttributes(interpolator,domElement,attrCtx); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_animation); ImageView view = new ImageView(this); view.setBackgroundResource(R.drawable.custom_button_selector); view.setScaleType(ImageView.ScaleType.CENTER); mReachability = new Reachability(this); mReachability.canTouchableBackView(true); mReachability.setBackImageResource(R.drawable.tiles); // Should call before makeHoverView! mReachability.setHoverView(view, android.R.drawable.ic_partial_secure, android.R.drawable.ic_secure); mReachability.makeHoverView(Reachability.Position.CENTER); mReachability.setCustomSlideInAnimation(1000, new AnticipateOvershootInterpolator(), fromLeftAnimation()); mReachability.setCustomSlideOutAnimation(1000, new AnticipateOvershootInterpolator(), toRightAnimation()); findViewById(R.id.switch_hover).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mReachability.switchHover(); } }); }
public static void rockBounce(final View theView) { theView.animate() .rotationXBy(30.0f) .setDuration(200) .setInterpolator(new AnticipateOvershootInterpolator()) .withEndAction(new Runnable() { @Override public void run() { theView.animate() .setDuration(100) .rotationX(0) .setInterpolator(new AnticipateOvershootInterpolator()) .start(); } }); }
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) { final View view = holder.itemView; ViewCompat.animate(view).cancel(); return ViewCompat.animate(view) .translationX(Utils.getScreenDimensions(holder.itemView.getContext()).x) .setInterpolator(new AnticipateOvershootInterpolator()); }
public void hide(float x) { this.lastPositionX = x; float offset = getOffset(x); int widthAdjustment = getWidthAdjustment(); AnimationSet animation = new AnimationSet(false); Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment, Animation.ABSOLUTE, widthAdjustment, Animation.RELATIVE_TO_SELF, -.25f, Animation.RELATIVE_TO_SELF, -.25f); scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f)); translateAnimation.setInterpolator(new DecelerateInterpolator()); animation.addAnimation(scaleAnimation); animation.addAnimation(translateAnimation); animation.setDuration(ANIMATION_DURATION); animation.setFillBefore(true); animation.setFillAfter(false); animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f)); recordButtonFab.setVisibility(View.GONE); recordButtonFab.clearAnimation(); recordButtonFab.startAnimation(animation); }
public static Interpolator parse(Integer type, Float cycles) { if (type != null) { switch (type) { case 0: return new AccelerateDecelerateInterpolator(); case 1: return new AccelerateInterpolator(); case 2: return new AnticipateInterpolator(); case 3: return new AnticipateOvershootInterpolator(); case 4: return new BounceInterpolator(); case 5: return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f); case 6: return new DecelerateInterpolator(); case 7: return new LinearInterpolator(); case 8: return new OvershootInterpolator(); //暂时不支持的 // case 7: return new FastOutLinearInterplator(); // case 8: return new FastOutSlowInInterplator(); // case 10: return new LinearOutSlowInInterplator(); // case 12: return new PathInterplator(); default: return new LinearInterpolator(); } } else { return new LinearInterpolator(); } }
/** * Creates interpolator. * * @param interpolatorType * @return */ public static TimeInterpolator createInterpolator(@IntRange(from = 0, to = 10) final int interpolatorType) { switch (interpolatorType) { case ACCELERATE_DECELERATE_INTERPOLATOR: return new AccelerateDecelerateInterpolator(); case ACCELERATE_INTERPOLATOR: return new AccelerateInterpolator(); case ANTICIPATE_INTERPOLATOR: return new AnticipateInterpolator(); case ANTICIPATE_OVERSHOOT_INTERPOLATOR: return new AnticipateOvershootInterpolator(); case BOUNCE_INTERPOLATOR: return new BounceInterpolator(); case DECELERATE_INTERPOLATOR: return new DecelerateInterpolator(); case FAST_OUT_LINEAR_IN_INTERPOLATOR: return new FastOutLinearInInterpolator(); case FAST_OUT_SLOW_IN_INTERPOLATOR: return new FastOutSlowInInterpolator(); case LINEAR_INTERPOLATOR: return new LinearInterpolator(); case LINEAR_OUT_SLOW_IN_INTERPOLATOR: return new LinearOutSlowInInterpolator(); case OVERSHOOT_INTERPOLATOR: return new OvershootInterpolator(); default: return new LinearInterpolator(); } }
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) { switch (interpolatorType) { case 0: animation.setInterpolator(new LinearInterpolator()); break; case 1: animation.setInterpolator(new AccelerateInterpolator()); break; case 2: animation.setInterpolator(new DecelerateInterpolator()); break; case 3: animation.setInterpolator(new AccelerateDecelerateInterpolator()); break; case 4: animation.setInterpolator(new BounceInterpolator()); break; case 5: animation.setInterpolator(new OvershootInterpolator()); break; case 6: animation.setInterpolator(new AnticipateInterpolator()); break; case 7: animation.setInterpolator(new AnticipateOvershootInterpolator()); break; default: break; } animation.setDuration(durationMillis); animation.setStartOffset(delayMillis); }
/** * NavHelper处理后,回调的方法 * @param newTab 新的Tab * @param oldTab 旧的Tab */ @Override public void onTabChanged(NavHelper.Tab<Integer> newTab, NavHelper.Tab<Integer> oldTab) { // 从额外字段中取出我们的Title资源Id title.setText(newTab.extra); // 对FloatButton进行隐藏和显示动画 float transY = 0; float rotation = 0; // 判断所处界面 if (Objects.equals(newTab.extra, R.string.title_home)) { transY = Ui.dipToPx(getResources(), 76); } else { // 此时Y默认为0===显示fb if (Objects.equals(newTab.extra, R.string.title_group)) { floatbutton.setImageResource(R.drawable.ic_group_add); rotation = -360; } else { // 联系人 floatbutton.setImageResource(R.drawable.ic_contact_add); rotation = 360; } } // 开始动画,旋转,Y轴惟一,弹性 floatbutton.animate() .rotation(rotation) .setInterpolator(new AnticipateOvershootInterpolator(1)) .translationY(transY) .setDuration(480) .start(); }
private void showEnterBtn() { if (clickTimes>=5 || SPHelper.getBoolean(KEY, false) || SPHelper.getBoolean(INTRODUCED,false)){ if (mEnterBtn.getVisibility()!=View.VISIBLE) { mEnterBtn.setVisibility(View.VISIBLE); mEnterBtn.setScaleY(0); mEnterBtn.setScaleX(0); mEnterBtn.setAlpha(0); mEnterBtn.animate().scaleX(1).scaleY(1).alpha(1) .setInterpolator(new AnticipateOvershootInterpolator()) .setStartDelay(500) .start(); } } }
private void transLabelX(boolean show) { if (labelHideTransX == -1) labelHideTransX = TDevice.dipToPx(getResources(), 52); if (show) { if (labelBeforeTransX == 0) return; else labelBeforeTransX = 0; } else { if (labelBeforeTransX == labelHideTransX) return; else labelBeforeTransX = labelHideTransX; } if (mTvLabel.getTag() == null) { mTvLabel.animate() .setInterpolator(new AnticipateOvershootInterpolator(2.5f)) .setDuration(260); mTvLabel.setTag(mTvLabel.animate()); } mTvLabel.animate() .translationXBy(mTvLabel.getTranslationX()) .translationX(labelBeforeTransX) .start(); }
public void animateIndicator(float indicator) { Interpolator interpolator = new AnticipateOvershootInterpolator(1.8f); ObjectAnimator animation = ObjectAnimator.ofFloat(this, "indicator", new float[]{indicator}); animation.setDuration(2000); animation.setInterpolator(interpolator); animation.start(); }
public void animateIndicator(float progress) { Interpolator interpolator = new AnticipateOvershootInterpolator(1.8f); ObjectAnimator animation = ObjectAnimator.ofFloat(this, "progress", new float[]{progress}); animation.setDuration(3000); animation.setInterpolator(interpolator); animation.start(); }
/** * Creates interpolator. * @return a timeinterpolator * @param interpolatorType a int value from 0 to 10 */ public static TimeInterpolator createInterpolator( @IntRange(from = 0, to = 10) final int interpolatorType) { switch (interpolatorType) { case ACCELERATE_DECELERATE_INTERPOLATOR: return new AccelerateDecelerateInterpolator(); case ACCELERATE_INTERPOLATOR: return new AccelerateInterpolator(); case ANTICIPATE_INTERPOLATOR: return new AnticipateInterpolator(); case ANTICIPATE_OVERSHOOT_INTERPOLATOR: return new AnticipateOvershootInterpolator(); case BOUNCE_INTERPOLATOR: return new BounceInterpolator(); case DECELERATE_INTERPOLATOR: return new DecelerateInterpolator(); case FAST_OUT_LINEAR_IN_INTERPOLATOR: return new FastOutLinearInInterpolator(); case FAST_OUT_SLOW_IN_INTERPOLATOR: return new FastOutSlowInInterpolator(); case LINEAR_INTERPOLATOR: return new LinearInterpolator(); case LINEAR_OUT_SLOW_IN_INTERPOLATOR: return new LinearOutSlowInInterpolator(); case OVERSHOOT_INTERPOLATOR: return new OvershootInterpolator(); default: return new LinearInterpolator(); } }
private void animateFAB(boolean start, View fab) { ViewCompat.animate(fab) .scaleX(start ? 1.0f : 0.0f) .scaleY(start ? 1.0f : 0.0f) .alpha(start ? 1.0f : 0.0f) .setDuration(start ? 300 : 100) .setInterpolator(new AnticipateOvershootInterpolator()) .withLayer() .start(); }
public void addCard(TinderCardView tc){ ViewGroup.LayoutParams layoutParams; layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int childCount = getChildCount(); addView(tc, 0, layoutParams); float scaleValue = 1 - (childCount/50.0f); tc.animate() .x(0) .y(childCount * yMultiplier) .scaleX(scaleValue) .setInterpolator(new AnticipateOvershootInterpolator()) .setDuration(DURATION); }
/** * Initializes wheel * @param id the wheel widget Id */ private void initWheel(int id) { WheelView wheel = getWheel(id); wheel.setViewAdapter(new NumericWheelAdapter(this, 0, 9)); wheel.setCurrentItem((int)(Math.random() * 10)); wheel.addChangingListener(changedListener); wheel.addScrollingListener(scrolledListener); wheel.setCyclic(true); wheel.setInterpolator(new AnticipateOvershootInterpolator()); }
/** * 重置下面的卡片 * @param position */ private void makeUnderViewReset(int position) { CardView underSlideView = slideViewMap.get(position); if (underSlideView != null) { int topMargin = (int) underSlideView.getTag(R.id.card_margin_top); float scale = (float) underSlideView.getTag(R.id.card_scale); int topPadding = underSlideView.getPaddingTop(); float curScale = underSlideView.getScaleX(); ValueAnimator paddingAnimator = ValueAnimator.ofInt(topPadding, topMargin); paddingAnimator.setTarget(underSlideView); paddingAnimator.setDuration(ANIM_DURATION); paddingAnimator.setInterpolator(new AnticipateOvershootInterpolator()); paddingAnimator.addUpdateListener((animation) -> { int padding = (int) animation.getAnimatedValue(); underSlideView.setPadding(0, padding, 0, 0); }); ValueAnimator scaleAnimator = ValueAnimator.ofFloat(curScale, scale); scaleAnimator.setTarget(underSlideView); scaleAnimator.setDuration(ANIM_DURATION); scaleAnimator.setInterpolator(new AnticipateOvershootInterpolator()); scaleAnimator.addUpdateListener(animation -> { float valueScale = (float) animation.getAnimatedValue(); underSlideView.setScaleX(valueScale); }); paddingAnimator.start(); scaleAnimator.start(); } }
@Override protected void animatePreviewViewDuringCameraTypeToggle(@NonNull ViewPropertyAnimator animator) { animator.rotationYBy(360) .setDuration(1500) .setInterpolator(new AnticipateOvershootInterpolator()) .start(); }
private void initInterpolations() { Class[] interpolations = { FastOutSlowInInterpolator.class, BounceInterpolator.class, LinearInterpolator.class, DecelerateInterpolator.class, CycleInterpolator.class, AnticipateInterpolator.class, AccelerateDecelerateInterpolator.class, AccelerateInterpolator.class, AnticipateOvershootInterpolator.class, FastOutLinearInInterpolator.class, LinearOutSlowInInterpolator.class, OvershootInterpolator.class}; try { interpolatorText = (Interpolator) interpolations[animateTextsEnter].newInstance(); interpolatorDrawablesEnter = (Interpolator) interpolations[animateDrawablesEnter].newInstance(); interpolatorSelector = (Interpolator) interpolations[animateSelector].newInstance(); interpolatorTextExit = (Interpolator) interpolations[animateTextsExit].newInstance(); interpolatorDrawablesExit = (Interpolator) interpolations[animateDrawablesExit].newInstance(); } catch (Exception e) { e.printStackTrace(); } }
public void start() { this.isStopped = false; leftHeartX = width / 4 + width / 8; leftHeartY = height / 4 + height / 8; PropertyValuesHolder widthPropertyHolder = PropertyValuesHolder.ofFloat(POSITION_X, width / 4 + width / 8, width / 2 + width / 8); PropertyValuesHolder heightPropertyHolder = PropertyValuesHolder.ofFloat(POSITION_Y, height / 4 + height / 8, height / 2 + height / 8); animatorLeftHeart = ValueAnimator.ofPropertyValuesHolder(widthPropertyHolder, heightPropertyHolder); animatorLeftHeart.setDuration(2000); animatorLeftHeart.setStartDelay(1000); animatorLeftHeart.setInterpolator(new AnticipateOvershootInterpolator()); animatorLeftHeart.addUpdateListener(leftHeartAnimationUpdateListener); animatorLeftHeart.setRepeatMode(ValueAnimator.REVERSE); animatorLeftHeart.setRepeatCount(ValueAnimator.INFINITE); widthPropertyHolder = PropertyValuesHolder.ofFloat(POSITION_X, width / 2 + width / 8, width / 4 + width / 8); heightPropertyHolder = PropertyValuesHolder.ofFloat(POSITION_Y, height / 4 + height / 8, height / 2 + height / 8); animatorRightHeart = ValueAnimator.ofPropertyValuesHolder(widthPropertyHolder, heightPropertyHolder); animatorRightHeart.setDuration(2000); animatorRightHeart.setInterpolator(new AnticipateOvershootInterpolator()); animatorRightHeart.addUpdateListener(rightHeartAnimationUpdateListener); animatorRightHeart.setRepeatCount(ValueAnimator.INFINITE); animatorRightHeart.setRepeatMode(ValueAnimator.REVERSE); animatorRightHeart.start(); animatorLeftHeart.start(); invalidate(); }
@Override public boolean isAttributeIgnored(AnticipateOvershootInterpolator resource, String namespaceURI, String name) { if (super.isAttributeIgnored(resource,namespaceURI,name)) return true; return NamespaceUtil.XMLNS_ANDROID.equals(namespaceURI) && (name.equals("tension") || name.equals("extraTension")); }
private static void initInterpolatorAnticipateOvershootTest(TestActivity act, View rootView,InflatedLayout layout) { TextView textView = getTextView(rootView,R.id.antOverInterpolatorTestId1); Animation animation = getAnimation(act,layout); AnticipateOvershootInterpolator interpolator = (AnticipateOvershootInterpolator)getInterpolator( R.anim.test_interpolator_anticipateovershoot_compiled, "@assets:anim/res/anim/test_interpolator_anticipateovershoot_asset.xml",act,layout); animation.setInterpolator(interpolator); textView.startAnimation(animation); Assert.assertEquals((Float)TestUtil.getField(interpolator,AnticipateOvershootInterpolator.class,"mTension"),3.0f * 2.0f); }
private static Animation outToBottomAnimation( final android.view.animation.Animation.AnimationListener animationlistener) { final TranslateAnimation translateanimation = new TranslateAnimation(2, 0F, 2, 0F, 2, 0F, 2, 1F); translateanimation.setDuration(500L); translateanimation.setInterpolator(new AnticipateOvershootInterpolator( 1.0f)); translateanimation.setAnimationListener(animationlistener); return translateanimation; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView1); btn01 = (Button) findViewById(R.id.button1); btn01.setOnClickListener(new MyOnClickListener(InterpolatorType.Accelerate)); btn02 = (Button) findViewById(R.id.button2); btn02.setOnClickListener(new MyOnClickListener(InterpolatorType.Decelerate)); btn03 = (Button) findViewById(R.id.button3); btn03.setOnClickListener(new MyOnClickListener(InterpolatorType.AccelerateDecelerate)); btn04 = (Button) findViewById(R.id.button4); btn04.setOnClickListener(new MyOnClickListener(InterpolatorType.LinearInterpolator)); btn05 = (Button) findViewById(R.id.button5); btn05.setOnClickListener(new MyOnClickListener(InterpolatorType.BounceInterpolator)); btn06 = (Button) findViewById(R.id.button6); btn06.setOnClickListener(new MyOnClickListener(InterpolatorType.AnticipateInterpolator)); btn07 = (Button) findViewById(R.id.button7); btn07.setOnClickListener(new MyOnClickListener(InterpolatorType.AnticipateOvershootInterpolator)); btn08 = (Button) findViewById(R.id.button8); btn08.setOnClickListener(new MyOnClickListener(InterpolatorType.CycleInterpolator)); btn09 = (Button) findViewById(R.id.button9); btn09.setOnClickListener(new MyOnClickListener(InterpolatorType.OvershootInterpolator)); }
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) { final View view = holder.itemView; ViewCompat.animate(view).cancel(); return ViewCompat.animate(view) .translationX(DisplayUtils.getScreenDimensions(holder.itemView.getContext()).x) .setInterpolator(new AnticipateOvershootInterpolator()); }
public View getView(int position, View convertView, ViewGroup parent) { View cellView; ColorCell colorView; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); cellView = inflater.inflate(R.layout.color_item, parent, false); if (animFadeInViewWhenAddNew && mNewlyAddedPosition == position) { cellView.setAlpha(0); cellView.setScaleX(.2f); cellView.setScaleY(.2f); cellView.animate().setInterpolator(new AnticipateOvershootInterpolator()).alpha(1).scaleX(1).scaleY(1).start(); mNewlyAddedPosition = -1; } int cellSize = parent.getHeight(); cellView.setMinimumHeight(cellSize); cellView.setMinimumWidth(cellSize); if (mCurSel == position) { cellView.setScaleX(1.2f); cellView.setScaleY(1.2f); } colorView = (ColorCell)cellView.findViewById(R.id.item_color); colorView.setMinimumHeight(cellSize - cellView.getPaddingTop() - cellView.getPaddingBottom()); colorView.setMinimumWidth(cellSize - cellView.getPaddingLeft() - cellView.getPaddingRight()); colorView.setColor(mColors.get(position)); return cellView; }
public static void rubberClick(final View theView) { ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(theView, "rotationY", 60f); ObjectAnimator rotateBack = ObjectAnimator.ofFloat(theView, "rotationY", 0f); ObjectAnimator scaleXDown = ObjectAnimator.ofFloat(theView, "scaleX", .4f); ObjectAnimator scaleYDown = ObjectAnimator.ofFloat(theView, "scaleY", .4f); ObjectAnimator scaleXBack = ObjectAnimator.ofFloat(theView, "scaleX", 1f); ObjectAnimator scaleYBack = ObjectAnimator.ofFloat(theView, "scaleY", 1f); AnimatorSet bouncer = new AnimatorSet(); bouncer.setInterpolator(new AnticipateOvershootInterpolator()); bouncer.play(scaleXDown).with(scaleYDown); bouncer.play(scaleXBack).with(scaleYBack); bouncer.play(scaleXBack).after(scaleXDown); bouncer.play(rotateAnim).after(scaleXBack); bouncer.play(rotateBack).after(rotateAnim); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(theView, "alpha", 0f); ObjectAnimator fadeBack = ObjectAnimator.ofFloat(theView, "alpha", 1f); fadeOut.setDuration(250); fadeBack.setDuration(250); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(bouncer).before(fadeOut); animatorSet.play(fadeBack).after(fadeOut); animatorSet.start(); // theView.animate().scaleX(.8f).scaleY(.8f).setDuration(200).setInterpolator(new AnticipateOvershootInterpolator()).withEndAction(new Runnable() { // @Override // public void run() { // theView.animate().setDuration(100).scaleX(1.0f).scaleY(1.0f).setInterpolator(new AnticipateOvershootInterpolator()).start(); // } // }); }