List of usage examples for android.view.animation AnimationSet setInterpolator
public void setInterpolator(Interpolator i)
From source file:Main.java
protected static void show(final View view) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setStartOffset(500);//from www .j av a2 s . co m fadeIn.setDuration(500); Animation collapse = new ScaleAnimation(1, 1, 0, 1); collapse.setDuration(500); AnimationSet animation = new AnimationSet(false); animation.setInterpolator(new AccelerateInterpolator()); animation.addAnimation(collapse); animation.addAnimation(fadeIn); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); view.startAnimation(animation); }
From source file:Main.java
public static void postAnimation(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;// ww w . ja v a 2 s .c o m } childLayout.setVisibility(View.INVISIBLE); childLayout.postDelayed(new Runnable() { @Override public void run() { childLayout.setVisibility(View.VISIBLE); AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(duration); animationSet.setInterpolator(new OvershootInterpolator(0.8f)); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
From source file:Main.java
public static void postAnimationBottom(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;// w w w.ja v a 2 s .c o m } childLayout.setVisibility(View.INVISIBLE); childLayout.postDelayed(new Runnable() { @Override public void run() { childLayout.setVisibility(View.VISIBLE); AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(duration); animationSet.setInterpolator(new AccelerateDecelerateInterpolator()); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
From source file:Main.java
public static AnimationSet ShuffleAnimation(int deltaX, int deltaY) { TranslateAnimation shake_1 = new TranslateAnimation(0, deltaX, 0, deltaY); shake_1.setDuration(400);// w w w.ja v a 2 s . c om shake_1.setStartOffset(0); shake_1.setFillAfter(true); TranslateAnimation shake_2 = new TranslateAnimation(0, -deltaX, 0, -deltaY); shake_2.setDuration(400); shake_2.setStartOffset(400); shake_2.setFillAfter(true); AnimationSet ShakeIt = new AnimationSet(true); ShakeIt.addAnimation(shake_1); ShakeIt.addAnimation(shake_2); ShakeIt.setInterpolator(new OvershootInterpolator()); return ShakeIt; }
From source file:Main.java
public static AnimationSet RotateAndFadeInAnimation() { AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f); fade_in.setDuration(400);//w w w .ja v a 2 s . c o m fade_in.setStartOffset(0); fade_in.setFillAfter(true); ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); expand.setDuration(500); expand.setStartOffset(0); expand.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); // rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_in); Reload.addAnimation(expand); Reload.addAnimation(rotate); Reload.setInterpolator(new DecelerateInterpolator(1.3f)); return Reload; }
From source file:Main.java
public static AnimationSet RotateAndFadeOutAnimation() { AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f); fade_out.setDuration(500);/*from w w w . jav a 2 s.co m*/ fade_out.setStartOffset(0); fade_out.setFillAfter(true); ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); shrink.setDuration(400); shrink.setStartOffset(0); shrink.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_out); Reload.addAnimation(shrink); Reload.addAnimation(rotate); Reload.setInterpolator(new AccelerateInterpolator(1.1f)); return Reload; }
From source file:Main.java
public static AnimationSet startInfoAnimation(int AnimationType, float fromX, float toX, float fromY, float toY, float scaleX, float scaleToX, float scaleY, float scaleToY, float pinX, float pinY) { OvershootInterpolator overshootInterpolator = new OvershootInterpolator(2f); AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation = new TranslateAnimation(AnimationType, fromX, AnimationType, toX, AnimationType, fromY, AnimationType, toY); ScaleAnimation scaleAnimation = new ScaleAnimation(scaleX, scaleToX, scaleY, scaleToY, AnimationType, pinX, AnimationType, pinY);/*from w w w. j ava 2 s .c om*/ animationSet.addAnimation(translateAnimation); animationSet.addAnimation(scaleAnimation); animationSet.setDuration(300); animationSet.setFillAfter(true); animationSet.setInterpolator(overshootInterpolator); return animationSet; }
From source file:com.capricorn.ArcMenu.java
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) { AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)); animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); animationSet.setDuration(duration);//from w w w .j a va 2s .co m animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setFillAfter(true); return animationSet; }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap, Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) { if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) { return;/* www.j av a 2 s .co m*/ } int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size(); boolean listenerRegistered = false; Animation.AnimationListener listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mVolumeGroupList.startAnimationAll(); mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }; // Animate visible items from previous positions to current positions except routes added // just before. Added routes will remain hidden until translate animation finishes. int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); Rect previousBounds = previousRouteBoundMap.get(route); int currentTop = view.getTop(); int previousTop = previousBounds != null ? previousBounds.top : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta); AnimationSet animSet = new AnimationSet(true); if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { previousTop = currentTop; Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); animSet.addAnimation(alphaAnim); } Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0); translationAnim.setDuration(mGroupListAnimationDurationMs); animSet.addAnimation(translationAnim); animSet.setFillAfter(true); animSet.setFillEnabled(true); animSet.setInterpolator(mInterpolator); if (!listenerRegistered) { listenerRegistered = true; animSet.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(animSet); previousRouteBoundMap.remove(route); previousRouteBitmapMap.remove(route); } // If a member route doesn't exist any longer, it can be either removed or moved out of the // ListView layout boundary. In this case, use the previously captured bitmaps for // animation. for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) { final MediaRouter.RouteInfo route = item.getKey(); final BitmapDrawable bitmap = item.getValue(); final Rect bounds = previousRouteBoundMap.get(route); OverlayObject object = null; if (mGroupMemberRoutesRemoved.contains(route)) { object = new OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f) .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator); } else { int deltaY = groupSizeDelta * mVolumeGroupListItemHeight; object = new OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY) .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator) .setAnimationEndListener(new OverlayObject.OnAnimationEndListener() { @Override public void onAnimationEnd() { mGroupMemberRoutesAnimatingWithBitmap.remove(route); mVolumeGroupAdapter.notifyDataSetChanged(); } }); mGroupMemberRoutesAnimatingWithBitmap.add(route); } mVolumeGroupList.addOverlayObject(object); } }
From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java
void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap, Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) { if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) { return;//from w w w. ja va 2 s. co m } int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size(); boolean listenerRegistered = false; Animation.AnimationListener listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mVolumeGroupList.startAnimationAll(); mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }; // Animate visible items from previous positions to current positions except routes added // just before. Added routes will remain hidden until translate animation finishes. int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); Rect previousBounds = previousRouteBoundMap.get(route); int currentTop = view.getTop(); int previousTop = previousBounds != null ? previousBounds.top : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta); AnimationSet animSet = new AnimationSet(true); if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { previousTop = currentTop; Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); animSet.addAnimation(alphaAnim); } Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0); translationAnim.setDuration(mGroupListAnimationDurationMs); animSet.addAnimation(translationAnim); animSet.setFillAfter(true); animSet.setFillEnabled(true); animSet.setInterpolator(mInterpolator); if (!listenerRegistered) { listenerRegistered = true; animSet.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(animSet); previousRouteBoundMap.remove(route); previousRouteBitmapMap.remove(route); } // If a member route doesn't exist any longer, it can be either removed or moved out of the // ListView layout boundary. In this case, use the previously captured bitmaps for // animation. for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) { final MediaRouter.RouteInfo route = item.getKey(); final BitmapDrawable bitmap = item.getValue(); final Rect bounds = previousRouteBoundMap.get(route); OverlayListView.OverlayObject object = null; if (mGroupMemberRoutesRemoved.contains(route)) { object = new OverlayListView.OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f) .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator); } else { int deltaY = groupSizeDelta * mVolumeGroupListItemHeight; object = new OverlayListView.OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY) .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator) .setAnimationEndListener(new OverlayListView.OverlayObject.OnAnimationEndListener() { @Override public void onAnimationEnd() { mGroupMemberRoutesAnimatingWithBitmap.remove(route); mVolumeGroupAdapter.notifyDataSetChanged(); } }); mGroupMemberRoutesAnimatingWithBitmap.add(route); } mVolumeGroupList.addOverlayObject(object); } }