private void bindHelpButton() { titleHelpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ScaleAnimation bounce = new ScaleAnimation(1.2f, 1f, 1.2f, 1, helpButtonSizePx / 2, helpButtonSizePx / 2); bounce.setDuration(600); bounce.setInterpolator(new BounceInterpolator()); if (helpLayout.getVisibility() == View.GONE) { showHelpOverlay(); titleHelpButton.setBackgroundResource(R.drawable.sr_close_icon); titleHelpButton.startAnimation(bounce); } else { hideHelpOverlay(); titleHelpButton.setBackgroundResource(R.drawable.sr_info_icon); titleHelpButton.startAnimation(bounce); } } }); }
@Override public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { this.targetView = view; preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView, PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight())) .setDuration(PRE_DURATION * 3); preAnimator.setInterpolator(new AccelerateInterpolator()); afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView, PropertyValuesHolder.ofFloat("translationX", view.getLeft() - view.getWidth(), view.getLeft())) .setDuration(AFTER_DURATION * 3); afterAnimator.setInterpolator(new BounceInterpolator()); preAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (action != null) { action.action(); } afterAnimator.start(); } }); return this; }
protected void onFinishInflate() { super.onFinishInflate(); if (!isInEditMode()) { TranslateAnimation translateAnimation = new TranslateAnimation(1, 2.0f, 1, 0.0f, 0, 0.0f, 0, 0.0f); translateAnimation.setDuration(1500); translateAnimation.setStartOffset(2500); translateAnimation.setInterpolator(new BounceInterpolator()); animate().setStartDelay(5500).alpha(0.0f).setDuration(400).withEndAction(new Runnable() { public void run() { ((ViewGroup) SplashScreenView.this.getParent()).removeView(SplashScreenView.this); } }); } }
/** * 启动动画 回弹效果 * */ private void startBackAnimator() { PropertyValuesHolder xValuesHolder = PropertyValuesHolder.ofFloat("x", canvasRotateX, 0); PropertyValuesHolder yValuesHolder = PropertyValuesHolder.ofFloat("y", canvasRotateY, 0); touchAnimator = ValueAnimator.ofPropertyValuesHolder(xValuesHolder, yValuesHolder).setDuration(700); touchAnimator.setInterpolator(new BounceInterpolator()); touchAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { canvasRotateY = (Float) animation.getAnimatedValue("y"); canvasRotateX = (Float) animation.getAnimatedValue("x"); invalidate(); } }); touchAnimator.start(); }
public ToolTip(){ /* default values */ mTitle = ""; mDescription = ""; mBackgroundColor = Color.parseColor("#3498db"); mTextColor = Color.parseColor("#FFFFFF"); mEnterAnimation = new AlphaAnimation(0f, 1f); mEnterAnimation.setDuration(1000); mEnterAnimation.setFillAfter(true); mEnterAnimation.setInterpolator(new BounceInterpolator()); mShadow = true; // TODO: exit animation mGravity = Gravity.CENTER; }
@Override protected void initViewsAndEvents() { Presenter splashPresenter = new SplashPresenter(this, this); splashPresenter.initialized(); ViewCompat.animate(fullscreenContent) .scaleX(1.0f) .scaleY(1.0f) .translationY(-100) .alpha(1f) .setInterpolator(new BounceInterpolator()) .setStartDelay(DateUtils.SECOND_IN_MILLIS) .setDuration(DateUtils.SECOND_IN_MILLIS * 2) .start(); }
@OnClick({R.id.start_window, R.id.jump_other}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.start_window: if (FloatWindow.get() != null) { return; } FloatPlayerView floatPlayerView = new FloatPlayerView(getApplicationContext()); FloatWindow .with(getApplicationContext()) .setView(floatPlayerView) .setWidth(Screen.width, 0.4f) .setHeight(Screen.width, 0.4f) .setX(Screen.width, 0.8f) .setY(Screen.height, 0.3f) .setMoveType(MoveType.slide) .setFilter(false) .setMoveStyle(500, new BounceInterpolator()) .build(); FloatWindow.get().show(); break; case R.id.jump_other: startActivity(new Intent(this, EmptyActivity.class)); break; } }
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 setPosition(Position position) { this.position = position; if (position == Position.BOTTOM) { if (getLayoutParams() instanceof FrameLayout.LayoutParams) { ((LayoutParams) getLayoutParams()).gravity = Gravity.BOTTOM; } else if (getLayoutParams() instanceof RelativeLayout.LayoutParams) { ((RelativeLayout.LayoutParams) getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } setAnimationInterpolator(new LinearInterpolator(), null); } else { if (getLayoutParams() instanceof FrameLayout.LayoutParams) { ((LayoutParams) getLayoutParams()).gravity = Gravity.TOP; } else if (getLayoutParams() instanceof RelativeLayout.LayoutParams) { ((RelativeLayout.LayoutParams) getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_TOP); } setAnimationInterpolator(new BounceInterpolator(), null); } }
private void dropPinEffect(Marker marker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long duration = 1500; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = Math.max(1 - interpolator.getInterpolation((float) elapsed / duration), 0); marker.setAnchor(0.5f, 1.0f + 14 * t); if (t > 0.0) { handler.postDelayed(this, 15); } else { marker.showInfoWindow(); } } }); }
private void setupView() { // 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator Interpolator polator = new BounceInterpolator(); mScroller = new Scroller(mContext, polator); // 获取屏幕分辨率 WindowManager wm = (WindowManager) (mContext .getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); mScreenHeigh = dm.heightPixels; mScreenWidth = dm.widthPixels; // 这里你一定要设置成透明背景,不然会影响你看到底层布局 this.setBackgroundColor(Color.argb(0, 0, 0, 0)); mImgView = new ImageView(mContext); mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mImgView.setScaleType(ImageView.ScaleType.FIT_XY);// 填充整个屏幕 // mImgView.setImageResource(R.drawable.ic_launcher); // 默认背景 mImgView.setBackgroundColor(Color.parseColor("#60000000")); addView(mImgView); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); mContext = this; users = getUsers(); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show(); swipeRefreshLayout.setRefreshing(false); } }); mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView); mRecyclerView.addItemDecoration(new VerticalSpaceItemDecoration(3)); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); // interpolator setting mRecyclerView.setOpenInterpolator(new BounceInterpolator()); mRecyclerView.setCloseInterpolator(new BounceInterpolator()); mAdapter = new AppAdapter(this, users); mRecyclerView.setAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); mContext = this; users = getUsers(); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show(); swipeRefreshLayout.setRefreshing(false); } }); mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView); mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); mRecyclerView.addItemDecoration(new StaggeredSpaceItemDecoration(15, 0, 15, 45)); // interpolator setting mRecyclerView.setOpenInterpolator(new BounceInterpolator()); mRecyclerView.setCloseInterpolator(new BounceInterpolator()); mAdapter = new AppAdapter(this, users); mRecyclerView.setAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); mContext = this; users = getUsers(); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show(); swipeRefreshLayout.setRefreshing(false); } }); mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); // interpolator setting mRecyclerView.setOpenInterpolator(new BounceInterpolator()); mRecyclerView.setCloseInterpolator(new BounceInterpolator()); mAdapter = new AppAdapter(this, users); mRecyclerView.setAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); mContext = this; users = getUsers(); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show(); swipeRefreshLayout.setRefreshing(false); } }); mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView); mRecyclerView.addItemDecoration(new GridSpaceItemDecoration(3, 3)); mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2)); mRecyclerView.setOpenInterpolator(new BounceInterpolator()); mRecyclerView.setCloseInterpolator(new BounceInterpolator()); mAdapter = new AppAdapter(this, users); mRecyclerView.setAdapter(mAdapter); }
@Override public void onRefreshing(MaterialRefreshLayout br) { setHeadHeight((int) (Util.dip2px(getContext(), DefaulHeadHeight))); ValueAnimator animator = ValueAnimator.ofInt(getWaveHeight(),0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //Log.i("anim", "value--->" + (int) animation.getAnimatedValue()); setWaveHeight((int) animation.getAnimatedValue()); invalidate(); } }); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(200); animator.start(); }
public void startAnimation(View[] views) { isOpen = true; fabReLayout.setVisibility(View.VISIBLE); if (VersionHelper.isAtLeast()) { /** *ObjectAnimator * */ for (int i = 0; i < views.length; i++) { objectAnimator = ObjectAnimator.ofFloat(views[i], "translationY", 0, -(i * 250)); objectAnimator.setStartDelay(i * 150); objectAnimator.setDuration(700); objectAnimator.setInterpolator(new BounceInterpolator()); objectAnimator.start(); } } else { /** *ViewCompat * */ for (int i = 0; i < views.length; i++) { ViewCompat.animate(views[i]).translationY(i * -ConverTool.px2dip(this, 400)).setDuration(600).setInterpolator(new BounceInterpolator()).start(); } } }
private void closeAnimation(View[] views) { isOpen = false; if (VersionHelper.isAtLeast()) { /** *ObjectAnimator * */ for (int i = 0; i < views.length; i++) { objectAnimator = ObjectAnimator.ofFloat(views[i], "translationY", i * 250, 0); objectAnimator.setStartDelay(i * 150); objectAnimator.setDuration(500); objectAnimator.setInterpolator(new BounceInterpolator()); objectAnimator.start(); } } else { /** *ViewCompat * */ for (int i = 0; i < views.length; i++) { ViewCompat.animate(views[i]).setDuration(500).translationY(0).start(); } } fabReLayout.setVisibility(View.GONE); }
private void launchCirclesAnimation() { circleTwo.setScaleX(0f); circleTwo.setScaleY(0f); circleThree.setScaleX(0f); circleThree.setScaleY(0f); ObjectAnimator animator = getCircleAnimation(circleOne, CIRCLE_ANIMATION_TIME); animator.setRepeatMode(ValueAnimator.RESTART); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new FastOutLinearInInterpolator()); animator.start(); ObjectAnimator animator2 = getCircleAnimation(circleTwo, CIRCLE_ANIMATION_TIME); animator2.setStartDelay(CIRCLE_ANIMATION_DELAY_ONE); animator2.setRepeatMode(ValueAnimator.RESTART); animator2.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new BounceInterpolator()); animator2.start(); ObjectAnimator animator3 = getCircleAnimation(circleThree, CIRCLE_ANIMATION_TIME); animator3.setStartDelay(CIRCLE_ANIMATION_DELAY_TWO); animator3.setRepeatMode(ValueAnimator.RESTART); animator3.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator3.start(); }
private void loadChart(float[] data) { BarSet dataSet = new BarSet(); float tempVal; for (int index = 0; index < data.length; index++) { tempVal = data[index]; dataSet.addBar(STATS[index], tempVal); stats[index].setText(String.valueOf(Math.round(tempVal))); } dataSet.setColor(ContextCompat.getColor(context, R.color.colorPrimary)); barChart.addData(dataSet); barChart.setXAxis(false); barChart.setYAxis(false); barChart.setYLabels(AxisRenderer.LabelPosition.NONE); Animation animation = new Animation(1000); animation.setInterpolator(new BounceInterpolator()); barChart.show(animation); }
@Override public void onRefreshing(MaterialRefreshLayout br) { setHeadHeight((int) (Util.dip2px(getContext(), DefaulHeadHeight))); ValueAnimator animator = ValueAnimator.ofInt(getWaveHeight(),0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Log.i("anim", "value--->" + (int) animation.getAnimatedValue()); setWaveHeight((int) animation.getAnimatedValue()); invalidate(); } }); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(200); animator.start(); }
public void testObjectAnimator(View v) { if (v.getId() == R.id.sdi_objectanimator_btn) { // 简单示例:View的横向移动 ObjectAnimator.ofFloat(mAnimView, "translationX", 0.0f, -200.0f) .setDuration(C.Int.ANIM_DURATION * 2) .start(); } else { // 复合示例:View弹性落下然后弹起,执行一次 ObjectAnimator yBouncer = ObjectAnimator.ofFloat(mAnimView, "y", mAnimView.getY(), 400.0f); yBouncer.setDuration(C.Int.ANIM_DURATION * 2); // 设置插值器(用于调节动画执行过程的速度) yBouncer.setInterpolator(new BounceInterpolator()); // 设置重复次数(缺省为0,表示不重复执行) yBouncer.setRepeatCount(1); // 设置重复模式(RESTART或REVERSE),重复次数大于0或INFINITE生效 yBouncer.setRepeatMode(ValueAnimator.REVERSE); // 设置动画开始的延时时间(200ms) yBouncer.setStartDelay(200); yBouncer.start(); } }
private Animation createFallDownAnimation() { AnimationSet a = new AnimationSet(false); a.setStartOffset(200); TranslateAnimation ta = new TranslateAnimation(0,0,0,0,1,-0.2f,0,0); ta.setInterpolator(new BounceInterpolator()); ta.setDuration(400); a.addAnimation(ta); AlphaAnimation aa = new AlphaAnimation(0,1); aa.setInterpolator(new AccelerateInterpolator()); aa.setDuration(200); a.addAnimation(aa); return a; }
void animateMarker(final Bitmap bitmap, final Marker marker) { if (marker == null) return; ValueAnimator animator = ValueAnimator.ofFloat(0.1f, 1); animator.setDuration(1000); animator.setStartDelay(500); animator.setInterpolator(new BounceInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float scale = (float) animation.getAnimatedValue(); try { marker.setIcon(BitmapDescriptorFactory.fromBitmap(DisplayUtils.resizeMarkerIcon(bitmap, Math.round(scale * 75), Math.round(scale * 75)))); } catch (IllegalArgumentException ex) { Log.e("MAPP", ex.getMessage()); } } }); animator.start(); }
public void setTimesAnimator() { AnimationBuilder builder = ViewAnimator.animate(mCountText); builder.scale(3.0f, 1f).interpolator(new BounceInterpolator()); builder.alpha(0f, 1f).interpolator(new BounceInterpolator()) .duration(900).onStop(new AnimationListener.Stop() { @Override public void onStop() { if (mIsContinue) { if (mCurrentContinueTimes < mContinueTimes) { setTimes(mCurrentTimes); setTimesAnimator(); mCurrentTimes++; mCurrentContinueTimes++; } else { mCurrentContinueTimes = 0; } } } }).start(); mHandler.removeCallbacks(mRunnable); mHandler.postDelayed(mRunnable, 3500L); }
private void setupNavigationController() { listTab = FragmentNavigationController.navigationController(this, R.id.tabContainer1); listTab.setPresentStyle(PresentStyle.ACCORDION_LEFT); listTab.setInterpolator(new AccelerateDecelerateInterpolator()); listTab.presentFragment(new FragmentFirst()); cardTab = FragmentNavigationController.navigationController(this, R.id.tabContainer2); cardTab.setPresentStyle(PresentStyle.ACCORDION_LEFT); cardTab.setInterpolator(new BounceInterpolator()); cardTab.presentFragment(new FragmentSecond()); tileTab = FragmentNavigationController.navigationController(this, R.id.tabContainer3); tileTab.setPresentStyle(PresentStyle.SLIDE_LEFT); tileTab.setInterpolator(new OvershootInterpolator()); tileTab.presentFragment(new FragmentThird()); currentNavigationController = listTab; }
private void startNewSteadyAnim() { final String propertyNameRotateX = "canvasRotateX"; final String propertyNameRotateY = "canvasRotateY"; PropertyValuesHolder holderRotateX = PropertyValuesHolder.ofFloat(propertyNameRotateX, canvasRotateX, 0); PropertyValuesHolder holderRotateY = PropertyValuesHolder.ofFloat(propertyNameRotateY, canvasRotateY, 0); steadyAnim = ValueAnimator.ofPropertyValuesHolder(holderRotateX, holderRotateY); steadyAnim.setDuration(1000); steadyAnim.setInterpolator(new BounceInterpolator()); steadyAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { canvasRotateX = (float) animation.getAnimatedValue(propertyNameRotateX); canvasRotateY = (float) animation.getAnimatedValue(propertyNameRotateY); } }); steadyAnim.start(); }
private void setMarkerBounce(final Marker marker) { final Handler handler = new Handler(); final long startTime = SystemClock.uptimeMillis(); final long duration = 2000; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - startTime; float t = Math.max( 1 - interpolator.getInterpolation((float) elapsed / duration), 0); marker.setAnchor(0.5f, 1.0f + t); if (t > 0.0) { handler.postDelayed(this, 16); } else { setMarkerBounce(marker); } } }); }
public void onLoadMore() { tvTip.setText(getContext().getString(R.string.loading)); mRainView.setVisibility(View.VISIBLE); mRainView.StartRain(); ValueAnimator animator = ValueAnimator.ofInt(-mWaveView.getmWaveHeight(), 0, mWaveAnimeHeight, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { // Log.d("anim", "value--->" + (int) animation.getAnimatedValue()); mWaveView.setmWaveHeight((int) animation.getAnimatedValue()); mWaveView.invalidate(); } }); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(1000); animator.start(); if (mListener != null) { mListener.onLoadMore(); } }
/** * 自由落体 * * @param view */ public void verticalRun(View view) { ValueAnimator animator = ValueAnimator.ofFloat(0, mScreenHeight - mBlueBall.getHeight()); //animator.setTarget(mBlueBall); animator.setDuration(1000).start(); animator.setInterpolator(new BounceInterpolator()); animator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mBlueBall.setTranslationY((Float) animation.getAnimatedValue()); } }); }
private void startAnim() { for(int i=1;i<ids.length;i++){ ObjectAnimator animator=ObjectAnimator.ofFloat(imageList.get(i), "translationY", 0F,i*80F); //设置加速插值器 //animator.setInterpolator(new AccelerateInterpolator()); //设置弹跳插值器 animator.setInterpolator(new BounceInterpolator()); animator.setDuration(1000); animator.setStartDelay(i*300); animator.start(); } }
public ToolTip(){ /* default values */ mTitle = ""; mDescription = ""; mBackgroundColor = Color.parseColor("#3498db"); mTextColor = Color.parseColor("#FFFFFF"); mEnterAnimation = new AlphaAnimation(0f, 1f); mEnterAnimation.setDuration(1000); mEnterAnimation.setFillAfter(true); mEnterAnimation.setInterpolator(new BounceInterpolator()); mShadow = true; mWidth = -1; // TODO: exit animation mGravity = Gravity.CENTER; }
public void startAnimation(RectAttribute newCoordinates, Animator.AnimatorListener listener) { RectAttribute oldCoordinates = new RectAttribute(this.mRoundRect.left, this.mRoundRect.top, this.mRoundRect.right, this.mRoundRect.bottom, this.mBorderRadius); ValueAnimator valueAnimator = ValueAnimator.ofObject(new RectAttributeEvaluator(), oldCoordinates, newCoordinates, oldCoordinates); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { currentCoordinates = (RectAttribute) animation.getAnimatedValue(); invalidate(); } }); valueAnimator.addListener(listener); valueAnimator.setInterpolator(new BounceInterpolator()); valueAnimator.setDuration(2666); valueAnimator.start(); }
public void enlargeReveal(View v) { RevealAnimator animator1 = new RevealAnimator(drawable); animator1.radius(100) .pivot(centerX, contentView.getHeight()) .interpolator(new BounceInterpolator()) .color(Color.CYAN); RevealAnimator animator2 = new RevealAnimator(drawable); animator2.radius(contentView.getHeight() + 100); RevealAnimator animator3 = new RevealAnimator(drawable); animator3.color(Color.YELLOW).duration(2000); animator1.withNextAnim(animator2.withNextAnim(animator3)).start(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public ObjectAnimator getSwipeInAnimator(View view, float deltaX, float deltaY){ float deltaXAbs = Math.abs(deltaX); float fractionCovered = 1.f - (deltaXAbs / view.getWidth()); long duration = Math.abs((int) ((1 - fractionCovered) * 200 * mSpeedFactor)); // Animate position and alpha of swiped item ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1.f), PropertyValuesHolder.ofFloat("translationX", 0.f), PropertyValuesHolder.ofFloat("rotationY", 0.f)); animator.setDuration(duration).setInterpolator(new BounceInterpolator()); return animator; }
private void init() { setText(getResources().getString(R.string.app_name).toLowerCase()); FontUtils.apply(this, FontUtils.ULTRA); if (!sDidAnimate && !isInEditMode()) { sDidAnimate = true; final ValueAnimator animator = ValueAnimator.ofFloat(1, 0); animator.addUpdateListener(anim -> setLetterSpacing((Float) anim.getAnimatedValue())); animator.setStartDelay(500L); animator.setDuration(2000L); animator.setInterpolator(new BounceInterpolator()); animator.start(); setAlpha(0); final ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(this, View.ALPHA, 0, 1); alphaAnimator.setStartDelay(500L); alphaAnimator.setDuration(1000L); alphaAnimator.setInterpolator(new FastOutSlowInInterpolator()); alphaAnimator.start(); } }
@SuppressLint("NewApi") private void setupView() { // 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator Interpolator polator = new BounceInterpolator(); mScroller = new Scroller(mContext, polator); // 获取屏幕分辨率 WindowManager wm = (WindowManager) (mContext .getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); mScreenHeigh = dm.heightPixels; mScreenWidth = dm.widthPixels; // 这里你一定要设置成透明背景,不然会影响你看到底层布局 this.setBackgroundColor(Color.argb(0, 0, 0, 0)); mImgView = new ImageView(mContext); mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mImgView.setScaleType(ImageView.ScaleType.FIT_XY);// 填充整个屏幕 mImgView.setImageResource(R.drawable.test); // 默认背景 addView(mImgView); }