@Override public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) { animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight())); animator.setDuration(3 * PRE_DURATION); animator.setInterpolator(new AnticipateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); resetView(view); if (action != null) { action.action(); } } }); return this; }
@Override public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) { animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("scaleX", 1, 0), PropertyValuesHolder.ofFloat("scaleY", 1, 0) ); animator.setDuration(3 * PRE_DURATION); animator.setInterpolator(new AnticipateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); resetView(view); if (action != null) { action.action(); } } }); return this; }
public void hide() { post(new Runnable() { @Override public void run() { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(ShareCard.this, "height", 0); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setVisibility(GONE); if (mListener != null) { mListener.onClick(ShareCard.this); } } }); objectAnimator.setDuration(500); objectAnimator.setInterpolator(new AnticipateInterpolator()); objectAnimator.setRepeatCount(0); objectAnimator.start(); } }); }
public void hide() { post(new Runnable() { @Override public void run() { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(IntroCard.this, "height", 0); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setVisibility(GONE); if (mListener != null) { mListener.onClick(IntroCard.this); } } }); objectAnimator.setDuration(500); objectAnimator.setInterpolator(new AnticipateInterpolator()); objectAnimator.setRepeatCount(0); objectAnimator.start(); } }); }
@SuppressWarnings("NewApi") private void hideMenu() { List<Animator> animList = new ArrayList<>(); for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) { animList.add(createHideItemAnimator(arcLayout.getChildAt(i))); } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(400); animSet.setInterpolator(new AnticipateInterpolator()); animSet.playTogether(animList); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); menuLayout.setVisibility(View.INVISIBLE); } }); animSet.start(); }
@SuppressWarnings("NewApi") private void hideMenu() { List<Animator> animList = new ArrayList<>(); for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) { animList.add(createHideItemAnimator(arcLayout.getChildAt(i))); } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(time); animSet.setInterpolator(new AnticipateInterpolator()); animSet.playTogether(animList); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); menuLayout.setVisibility(View.GONE); } }); animSet.start(); }
static void hideMenu(ViewGroup viewGroup, Point touchPoint) { List<Animator> animList = new ArrayList<>(); for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) { animList.add(createHideItemAnimator(viewGroup.getChildAt(i), touchPoint)); } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(ANIM_DURATION); animSet.setInterpolator(new AnticipateInterpolator()); animSet.playTogether(animList); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); } }); animSet.start(); }
static void openMenu(ViewGroup viewGroup, int openIndex, AnimatorListenerAdapter endListener) { List<Animator> animList = new ArrayList<>(); for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) { if (openIndex == i) { animList.add(createOpenItemAnimator(viewGroup.getChildAt(i))); } else { animList.add(createStayHideItemAnimator(viewGroup.getChildAt(i))); } } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(ANIM_DURATION); animSet.setInterpolator(new AnticipateInterpolator()); animSet.playTogether(animList); animSet.addListener(endListener); animSet.start(); }
/** * 启动取消动画 */ private void startCancelMenuAnima() { ValueAnimator cancelAnima = ValueAnimator.ofFloat(1.f, 100.f); cancelAnima.setDuration(500); cancelAnima.setInterpolator(new AnticipateInterpolator()); cancelAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { fraction = valueAnimator.getAnimatedFraction(); itemMenuRadius = (1 - fraction) * partSize; itemIconSize = (int) ((1 - fraction) * iconSize); invalidate(); } }); cancelAnima.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { status = STATUS_MENU_CLOSED; if (onMenuStatusChangeListener != null) onMenuStatusChangeListener.onMenuClosed(); } }); cancelAnima.start(); }
public static void acceptAndClear(final EditText editText) { Spannable text = editText.getText(); if (TextUtils.isEmpty(text)) { return; } PropertySpan propertySpan = new PropertySpan(editText); propertySpan.setClipOffset(0, editText.getResources().getDimensionPixelOffset(R.dimen.clip_offset_bottom)); text.setSpan(propertySpan, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); editText.setText(text); ObjectAnimator moveUp = ObjectAnimator.ofFloat(propertySpan, PropertySpan.TRANSLATION_Y, 0, -editText.getHeight() / 4); moveUp.setDuration(300); moveUp.setInterpolator(new AnticipateInterpolator()); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(propertySpan, PropertySpan.ALPHA, 1, 0); fadeOut.setDuration(300); AnimatorSet set = new AnimatorSet(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { editText.setText(null); } }); set.playTogether(moveUp, fadeOut); set.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(); } }
public void updateTransition(View v) { mDrawerListenerAdapter.removeAllTransitions(); ViewTransitionBuilder builder = ViewTransitionBuilder.transit(mGradient).translationX(-mGradient.getWidth(), 0); switch (v.getId()) { case R.id.interpolator_default: break; case R.id.interpolator_linear: builder.interpolator(new LinearInterpolator()); break; case R.id.interpolator_accelerate: builder.interpolator(new AccelerateInterpolator()); break; case R.id.interpolator_decelerate: builder.interpolator(new DecelerateInterpolator()); break; case R.id.interpolator_fastout: builder.interpolator(new FastOutLinearInInterpolator()); break; case R.id.interpolator_anticipate: builder.interpolator(new AnticipateInterpolator()); break; } mDrawerListenerAdapter.addTransition(builder); }
private void animateSignalSlide(final boolean reverse) { float layoutTY = fingerPrintLayout.getTranslationY(); if (!reverse) { fingerPrintLayout.setTranslationY(layoutTY + BreadActivity.screenParametersPoint.y); fingerPrintLayout.animate() .translationY(layoutTY) .setDuration(ANIMATION_DURATION + 200) .setInterpolator(new DecelerateOvershootInterpolator(2.0f, 1f)) .withLayer(); } else { fingerPrintLayout.animate() .translationY(1500) .setDuration(ANIMATION_DURATION) .withLayer().setInterpolator(new AnticipateInterpolator(2f)).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (getActivity() != null) getActivity().getFragmentManager().beginTransaction().remove(FragmentFingerprint.this).commit(); } }); } }
/** * Style 3 animation will turn a 3/4 animation with Anticipate/Overshoot interpolation to a * blank waiting - like state, wait for 2 seconds then return to the original state * * @return Animation */ private Animator prepareStyle3Animation() { AnimatorSet animation = new AnimatorSet(); ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0.75f, 0f); progressAnimation.setDuration(1200); progressAnimation.setInterpolator(new AnticipateInterpolator()); Animator innerCircleAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0.75f, 0f); innerCircleAnimation.setDuration(1200); innerCircleAnimation.setInterpolator(new AnticipateInterpolator()); ObjectAnimator invertedProgress = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0f, 0.75f); invertedProgress.setDuration(1200); invertedProgress.setStartDelay(3200); invertedProgress.setInterpolator(new OvershootInterpolator()); Animator invertedCircle = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0f, 0.75f); invertedCircle.setDuration(1200); invertedCircle.setStartDelay(3200); invertedCircle.setInterpolator(new OvershootInterpolator()); animation.playTogether(progressAnimation, innerCircleAnimation, invertedProgress, invertedCircle); return 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(); } }
@Override public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { this.targetView = view; preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight())) .setDuration(PRE_DURATION * 3); preAnimator.setInterpolator(new AnticipateInterpolator()); afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView, PropertyValuesHolder.ofFloat("translationX", view.getRight(), view.getLeft())) .setDuration(AFTER_DURATION * 2); afterAnimator.setInterpolator(new BounceInterpolator()); preAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); targetView.setAlpha(1); if (action != null) { action.action(); } afterAnimator.start(); } }); return this; }
/** * 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); }
public void onConfirm(View view) { final Model model = checkInputs(); if (model == null) { return; } final Intent intent = new Intent(this, MainService.class); intent.putExtra(MainService.ACTION_KEY, MainService.ACTION_TRAIN); intent.putExtra(MainService.EXTRAS_NEURAL_CONFIG, model); startService(intent); final int height = mContainer.getHeight(); final Activity that = this; mPage.setClickable(false); mContainer.animate() .y(-height) .alpha(0F) .setInterpolator(new AnticipateInterpolator()) .setDuration(300) .withEndAction(new Runnable() { @Override public void run() { if (!that.isFinishing()) { that.finish(); } } }).start(); Tracker.getInstance() .event(TrackCons.Model.CLICK_TRAIN) .put(TrackCons.Key.MSG, snapshot(model)) .log(); }
private void initAuraAnimators(final int index, ValueAnimator opacityAnimator) { opacityAnimator.setRepeatMode(ValueAnimator.REVERSE); final float opacityDecelerateFactor = 1.f + 0.8f * (index + 1); opacityAnimator.setInterpolator(new AnticipateInterpolator(opacityDecelerateFactor)); opacityAnimator.setIntValues(255, 50, 255, 50); opacityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { final int opacity = (int) animation.getAnimatedValue(); mAlphaOpacityList.set(index, opacity); } }); }
private void startAnimation() { ObjectAnimator oa = ObjectAnimator.ofFloat(mIvPic, "translationY", 0, 400); // 加速减速插值器 // AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator(); // 加速插值器 // AccelerateInterpolator interpolator = new AccelerateInterpolator(0.8f); // 回荡秋千插值器 AnticipateInterpolator interpolator = new AnticipateInterpolator(0.8f); oa.setInterpolator(interpolator); oa.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(); } }
public void setAnimatedPoints(int animatedPoints) { float dist = 1f / (float) (animatedPoints - 2); // Interpolator interpolator = new AccelerateInterpolator(); // Interpolator interpolator = new DecelerateInterpolator(); Interpolator interpolator = new AnticipateInterpolator(); mFactor = new float[animatedPoints]; for (int i = 0; i < animatedPoints - 1; i++) { mFactor[i] = 1f + interpolator.getInterpolation(dist * i); } mFactor[animatedPoints - 1] = 1f; }
private void initView() { // tv = (MarqueTextView) findViewById(R.id.tv_marque); // Timer timer = new Timer(); // TimerTask task = new TimerTask() { // @Override // public void run() { // index ++; // if (index > 2) { // index = 0; // } // MainActivity.this.runOnUiThread(new Runnable() { // @Override // public void run() { // tv.setText(names[index]); // } // }); // // } // }; // timer.schedule(task,1000,1000); findViewById(R.id.iv_head).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("aaaa","onclick"); // v.animate().setDuration(1000).scaleX(2).scaleY(2).setInterpolator(new BounceInterpolator()).start(); AnimatorSet set = new AnimatorSet(); set.setInterpolator(new AnticipateInterpolator()); set.playTogether( ObjectAnimator.ofFloat(v,"scaleX",1f,2f), ObjectAnimator.ofFloat(v,"scaleX",2f,1f), ObjectAnimator.ofFloat(v,"scaleY",1f,2f), ObjectAnimator.ofFloat(v,"scaleY",2f,1f)); set.setDuration(1000).start(); } }); }
@Override public void onSelectChanged(View v, boolean selected) { int end = selected ? 360 : 0; ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(v, "rotation", end); rotateAnimator.setDuration(400); rotateAnimator.setInterpolator(new AnticipateInterpolator()); rotateAnimator.start(); }
@Override public void onSelectChanged(View v, boolean selected) { int end = selected?-10:0; ObjectAnimator jumpAnimator = ObjectAnimator.ofFloat(v,"translationY",end); jumpAnimator.setDuration(300); jumpAnimator.setInterpolator(new AnticipateInterpolator()); jumpAnimator.start(); }
/** * Make a shrink animation. * @param duration * @return */ public static Animator shrinkAnimator(int duration){ AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator xExpandAnimator = new ObjectAnimator(); xExpandAnimator.setPropertyName("scaleX"); xExpandAnimator.setFloatValues(1.0f, 0.5f); ObjectAnimator yExpandAnimator = new ObjectAnimator(); yExpandAnimator.setPropertyName("scaleY"); yExpandAnimator.setFloatValues(1.0f, 0.5f); animatorSet.play(xExpandAnimator).with(yExpandAnimator); animatorSet.setDuration(duration); animatorSet.setInterpolator(new AnticipateInterpolator()); return animatorSet; }
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(); } }
@Override protected void createTracks() { if (getView() != null) { createTracks(R.id.dynamicArcView1, new LinearInterpolator(), Color.parseColor("#CC0000")); createTracks(R.id.dynamicArcView2, new AnticipateInterpolator(), Color.parseColor("#048482")); createTracks(R.id.dynamicArcView3, new AccelerateInterpolator(), Color.parseColor("#003366")); createTracks(R.id.dynamicArcView4, new DecelerateInterpolator(), Color.parseColor("#66A7C5")); createTracks(R.id.dynamicArcView5, new BounceInterpolator(), Color.parseColor("#FF6000")); createTracks(R.id.dynamicArcView6, new OvershootInterpolator(), Color.parseColor("#6F0564")); } }
private static void initInterpolatorAnticipateTest(TestActivity act, View rootView,InflatedLayout layout) { TextView textView = getTextView(rootView,R.id.anticipateInterpolatorTestId1); Animation animation = getAnimation(act,layout); AnticipateInterpolator interpolator = (AnticipateInterpolator)getInterpolator( R.anim.test_interpolator_anticipate_compiled, "@assets:anim/res/anim/test_interpolator_anticipate_asset.xml",act,layout); animation.setInterpolator(interpolator); textView.startAnimation(animation); Assert.assertEquals((Float)TestUtil.getField(interpolator,AnticipateInterpolator.class,"mTension"),4.0f); }
@Override public void onNextPressed() { switch (++currentStep) { case 2: gif1.setVisibility(View.VISIBLE); Utils.startGif(gif1); break; case 3: gif2.setVisibility(View.VISIBLE); Utils.stopGif(gif1); Utils.startGif(gif2); break; case 4: Utils.stopGif(gif2); gif1.animate().translationX(-gif1.getWidth()).alpha(0f) .setStartDelay(0).setInterpolator(new AnticipateInterpolator(1f)); gif2.animate().translationX(gif2.getWidth()).alpha(0f) .setStartDelay(0).setInterpolator(new AnticipateInterpolator(1f)); gif3.setVisibility(View.VISIBLE); Utils.startGif(gif3); gif3.setAlpha(0f); gif3.setScaleX(0f); gif3.setScaleY(0f); gif3.animate().alpha(1f).scaleY(1f).scaleX(1f) .setInterpolator(new OvershootInterpolator(5f)) .setStartDelay(200).setDuration(500); break; case 5: ((MainActivity) getActivity()).nextFragment(); } }
@Override public void onPrevPressed() { if (--currentStep > 0) { switch (currentStep) { case 1: gif1.setVisibility(View.GONE); Utils.stopGif(gif1); break; case 2: Utils.startGif(gif1); Utils.stopGif(gif2); gif2.setVisibility(View.GONE); break; case 3: gif1.animate().translationX(1f).alpha(1f) .setStartDelay(400).setInterpolator(new OvershootInterpolator(1f)); gif2.animate().translationX(1f).alpha(1f) .setStartDelay(400).setInterpolator(new OvershootInterpolator(1f)); gif3.animate().alpha(0f).scaleY(0f).scaleX(0f) .setInterpolator(new AnticipateInterpolator(3f)) .setStartDelay(0).setDuration(500); Utils.stopGif(gif3); Utils.startGif(gif2); } return; } super.onPrevPressed(); }
@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)); }
/** * Initialized animation properties */ private void calculateAnimationProportions() { TRANSLATION_Y = sHeight * buttonDistanceY; TRANSLATION_X = sWidth * buttonDistanceX; anticipation = new AnticipateInterpolator(INTERPOLATOR_WEIGHT); overshoot = new OvershootInterpolator(INTERPOLATOR_WEIGHT); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @OnClick({R.id.LinearInterpolator, R.id.AccelerateDecelerateInterpolator, R.id.AccelerateInterpolator, R.id.AnticipateInterpolator, R.id.BounceInterpolator, R.id.CycleInterpolator, R.id.DecelerateInterpolator, R.id.AnticipateOvershootInterpolator, R.id.OvershootInterpolator, R.id.PathInterpolator}) public void onClick(View view) { switch (view.getId()) { //匀速线性 case R.id.LinearInterpolator: objectAnimator.setInterpolator(new LinearInterpolator()); break; //先加速后减速 case R.id.AccelerateDecelerateInterpolator: objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); break; //一直加速 case R.id.AccelerateInterpolator: objectAnimator.setInterpolator(new AccelerateInterpolator()); break; //反向移动然后正向加速 case R.id.AnticipateInterpolator: objectAnimator.setInterpolator(new AnticipateInterpolator()); break; //加速下落回弹 case R.id.BounceInterpolator: objectAnimator.setInterpolator(new BounceInterpolator()); break; //循环播放 参数指定循环次数 case R.id.CycleInterpolator: objectAnimator.setInterpolator(new CycleInterpolator(2f)); break; //减速效果 case R.id.DecelerateInterpolator: objectAnimator.setInterpolator(new DecelerateInterpolator()); break; //反向超过原来位置 然后正向加速超过规定位置 返回 case R.id.AnticipateOvershootInterpolator: objectAnimator.setInterpolator(new AnticipateOvershootInterpolator()); break; //向前甩一定值后再回到原来位置 可以传值指定加速度值 case R.id.OvershootInterpolator: objectAnimator.setInterpolator(new OvershootInterpolator()); break; case R.id.PathInterpolator: Intent intent=new Intent(InterpolatorActivity.this,InterpolatorPathActivity.class); startActivity(intent); break; } objectAnimator.start(); }
private void init(Context context, AttributeSet attrs) { TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0); mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing); mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin); mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT); mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation, R.anim.bottom_in); mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation, R.anim.bottom_out); mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop); mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight); mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom); mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft); mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor); // set default value if null same as for textview if (mLabelsTextColor == null) { mLabelsTextColor = ColorStateList.valueOf(Color.WHITE); } mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size)); mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius); mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true); mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333); mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444); mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF); mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true); mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000); mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius); mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset); mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset); mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336); mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043); mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF); mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50); mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon); if (mIcon == null) { mIcon = getResources().getDrawable(R.drawable.ic_add_fab); } mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false); mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0); mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1); mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL); mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0); mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP); mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.RED); if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) { mUsingMenuLabel = true; mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label); } if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) { int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0); initPadding(padding); } mOpenInterpolator = new OvershootInterpolator(); mCloseInterpolator = new AnticipateInterpolator(); mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle); initBackgroundDimAnimation(); createMenuButton(); initMenuButtonAnimations(attr); attr.recycle(); }
private void init(Context context, AttributeSet attrs) { TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0); mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing); mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin); mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT); mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left); mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left); mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop); mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight); mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom); mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft); mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor); // set default value if null same as for textview if (mLabelsTextColor == null) { mLabelsTextColor = ColorStateList.valueOf(Color.WHITE); } mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size)); mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius); mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true); mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333); mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444); mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF); mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true); mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000); mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius); mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset); mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset); mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336); mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043); mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF); mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50); mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon); if (mIcon == null) { // mIcon = getResources().getDrawable(R.drawable.fab_add); } mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false); mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0); mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1); mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL); mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0); String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont); try { if (!TextUtils.isEmpty(customFont)) { mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont); } } catch (RuntimeException ex) { throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex); } mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP); mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT); if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) { mUsingMenuLabel = true; mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label); } if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) { int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0); initPadding(padding); } mOpenInterpolator = new OvershootInterpolator(); mCloseInterpolator = new AnticipateInterpolator(); mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle); initBackgroundDimAnimation(); createMenuButton(); initMenuButtonAnimations(attr); attr.recycle(); this.requestFocus(); this.setFocusableInTouchMode(true); }