Java Examples for android.animation.ObjectAnimator
The following java examples will help you to understand the usage of android.animation.ObjectAnimator. These source code samples are taken from different open source projects.
Example 1
| Project: FlycoDialog_Master-master File: BounceEnter.java View source code |
@Override
public void setAnimation(View view) {
animatorSet.playTogether(//
ObjectAnimator.ofFloat(//
view, //
"alpha", //
0, //
1, //
1, //
1), ObjectAnimator.ofFloat(view, "scaleX", 0.5f, 1.05f, 0.95f, 1), ObjectAnimator.ofFloat(view, "scaleY", 0.5f, 1.05f, 0.95f, 1));
/**
* <pre>
* �一�弹性实现:��sweet-alert-dialog布局文件实现
* ObjectAnimator oa_alpha = ObjectAnimator.ofFloat(view, "alpha", 0.2f, 1).setDuration(90);
*
* AnimatorSet as1 = new AnimatorSet();
* as1.playTogether(oa_alpha, ObjectAnimator.ofFloat(view, "scaleX", 0.7f, 1.05f).setDuration(135),//
* ObjectAnimator.ofFloat(view, "scaleY", 0.7f, 1.05f).setDuration(135));
*
* AnimatorSet as2 = new AnimatorSet();
* as2.playTogether(ObjectAnimator.ofFloat(view, "scaleX", 1.05f, 0.95f).setDuration(105), //
* ObjectAnimator.ofFloat(view, "scaleY", 1.05f, 0.95f).setDuration(105));
*
* AnimatorSet as3 = new AnimatorSet();
* as3.playTogether(ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 1f).setDuration(60),//
* ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 1f).setDuration(60));
*
* animatorSet.playSequentially(as1, as2, as3);
* </pre>
*
*/
}Example 2
| Project: SprintNBA-master File: BounceEnter.java View source code |
@Override
public void setAnimation(View view) {
animatorSet.playTogether(//
ObjectAnimator.ofFloat(//
view, //
"alpha", //
0, //
1, //
1, //
1), ObjectAnimator.ofFloat(view, "scaleX", 0.5f, 1.05f, 0.95f, 1), ObjectAnimator.ofFloat(view, "scaleY", 0.5f, 1.05f, 0.95f, 1));
/**
* <pre>
* �一�弹性实现:��sweet-alert-dialog布局文件实现
* ObjectAnimator oa_alpha = ObjectAnimator.ofFloat(view, "alpha", 0.2f, 1).setDuration(90);
*
* AnimatorSet as1 = new AnimatorSet();
* as1.playTogether(oa_alpha, ObjectAnimator.ofFloat(view, "scaleX", 0.7f, 1.05f).setDuration(135),//
* ObjectAnimator.ofFloat(view, "scaleY", 0.7f, 1.05f).setDuration(135));
*
* AnimatorSet as2 = new AnimatorSet();
* as2.playTogether(ObjectAnimator.ofFloat(view, "scaleX", 1.05f, 0.95f).setDuration(105), //
* ObjectAnimator.ofFloat(view, "scaleY", 1.05f, 0.95f).setDuration(105));
*
* AnimatorSet as3 = new AnimatorSet();
* as3.playTogether(ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 1f).setDuration(60),//
* ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 1f).setDuration(60));
*
* animatorSet.playSequentially(as1, as2, as3);
* </pre>
*
*/
}Example 3
| Project: AndroidViewAnimations-master File: ZoomOutRightAnimator.java View source code |
@Override
protected void prepare(View target) {
ViewGroup parent = (ViewGroup) target.getParent();
int distance = parent.getWidth() - parent.getLeft();
getAnimatorAgent().playTogether(ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0), ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f), ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f), ObjectAnimator.ofFloat(target, "translationX", 0, -42, distance));
}Example 4
| Project: ExpectAnim-master File: ExpectAnimRotationManager.java View source code |
@Override
public List<Animator> getAnimators() {
final List<Animator> animations = new ArrayList<>();
calculate();
if (rotation != null) {
animations.add(ObjectAnimator.ofFloat(viewToMove, View.ROTATION, rotation));
}
if (rotationX != null) {
animations.add(ObjectAnimator.ofFloat(viewToMove, View.ROTATION_X, rotationX));
}
if (rotationY != null) {
animations.add(ObjectAnimator.ofFloat(viewToMove, View.ROTATION_Y, rotationY));
}
return animations;
}Example 5
| Project: platform_sdk-master File: CustomPropertyAnimationActivity.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout container = (LinearLayout) findViewById(R.id.container);
MyView view = new MyView(this);
container.addView(view);
ObjectAnimator anim = ObjectAnimator.ofFloat(view, "foo", 1);
anim.start();
}Example 6
| Project: DMPlayer-master File: DMPlayerUtility.java View source code |
public static void animateHeartButton(final View v) {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f);
rotationAnim.setDuration(300);
rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1f);
bounceAnimX.setDuration(300);
bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR);
ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1f);
bounceAnimY.setDuration(300);
bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR);
bounceAnimY.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
});
animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim);
animatorSet.start();
}Example 7
| Project: android-tutorials-glide-master File: UsageExampleAnimate.java View source code |
private void loadImageAnimateCode() {
ViewPropertyAnimation.Animator animationObject = new ViewPropertyAnimation.Animator() {
@Override
public void animate(View view) {
view.setAlpha(0f);
ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeAnim.setDuration(2500);
fadeAnim.start();
}
};
Glide.with(context).load(eatFoodyImages[1]).animate(animationObject).into(imageView2);
}Example 8
| Project: demos-master File: TestInterpolatorActivity.java View source code |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_interpolator);
View viewById = findViewById(R.id.iv);
PathInterpolator pathInterpolator = new PathInterpolator(1.0f, 1.0f);
final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(viewById, "translationX", 0f, 500f).setDuration(1000);
objectAnimator.setInterpolator(pathInterpolator);
viewById.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
objectAnimator.start();
}
});
}Example 9
| Project: FloatingText-master File: TranslateFloatingAnimator.java View source code |
@Override
public void applyFloatingAnimation(final FloatingTextView view) {
view.setTranslationY(0);
view.setAlpha(1f);
view.setScaleX(0f);
view.setScaleY(0f);
Spring scaleAnim = createSpringByBouncinessAndSpeed(10, 15).addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float transition = transition((float) spring.getCurrentValue(), 0.0f, 1.0f);
view.setScaleX(transition);
view.setScaleY(transition);
}
});
ValueAnimator translateAnimator = ObjectAnimator.ofFloat(0, translateY);
translateAnimator.setDuration(duration);
translateAnimator.setStartDelay(50);
translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
view.setTranslationY((Float) valueAnimator.getAnimatedValue());
}
});
translateAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setTranslationY(0);
view.setAlpha(0f);
}
});
ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
alphaAnimator.setDuration(duration);
alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
view.setAlpha((Float) valueAnimator.getAnimatedValue());
}
});
scaleAnim.setEndValue(1f);
alphaAnimator.start();
translateAnimator.start();
}Example 10
| Project: FrescoImageViewer-master File: AnimationUtils.java View source code |
static void animateVisibility(final View view) {
final boolean isVisible = view.getVisibility() == View.VISIBLE;
float from = isVisible ? 1.0f : 0.0f, to = isVisible ? 0.0f : 1.0f;
ObjectAnimator animation = ObjectAnimator.ofFloat(view, "alpha", from, to);
animation.setDuration(ViewConfiguration.getDoubleTapTimeout());
if (isVisible) {
animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
}
});
} else
view.setVisibility(View.VISIBLE);
animation.start();
}Example 11
| Project: hintcase-master File: FadeOutShapeAnimator.java View source code |
@Override
public ValueAnimator getAnimator(View view, Shape shape, final OnFinishListener onFinishListener) {
shape.setMinimumValue();
ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
animator.setDuration(durationInMilliseconds);
animator.setStartDelay(startDelayInMilliseconds);
if (onFinishListener != NO_CALLBACK) {
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
onFinishListener.onFinish();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
return animator;
}Example 12
| Project: kickmaterial-master File: AnimatorUtils.java View source code |
public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
set.playTogether(scaleXAnimator, scaleYAnimator);
return set;
}Example 13
| Project: springmenu-master File: TranslateAnimation.java View source code |
public static void startTranslationAnimator(final View view, final float targetX, final float targetY, int duration, BaseAnimatorListener listener) {
final ObjectAnimator animatorX = ObjectAnimator.ofFloat(view, "translationX", view.getTranslationX(), targetX);
final ObjectAnimator animatorY = ObjectAnimator.ofFloat(view, "translationY", view.getTranslationY(), targetY);
AnimatorSet animationSet = new AnimatorSet();
animationSet.setInterpolator(new LinearInterpolator());
animationSet.setDuration(duration);
animationSet.playTogether(animatorX, animatorY);
if (listener != null) {
animationSet.addListener(listener);
}
animationSet.start();
}Example 14
| Project: weiciyuan-master File: PointAnimator.java View source code |
public static Animator ofPoints(Object object, String xMethod, String yMethod, Point... values) {
AnimatorSet set = new AnimatorSet();
int[] xValues = new int[values.length];
int[] yValues = new int[values.length];
for (int i = 0; i < values.length; i++) {
xValues[i] = values[i].x;
yValues[i] = values[i].y;
}
ObjectAnimator xAnimator = ObjectAnimator.ofInt(object, xMethod, xValues);
ObjectAnimator yAnimator = ObjectAnimator.ofInt(object, yMethod, yValues);
set.playTogether(xAnimator, yAnimator);
return set;
}Example 15
| Project: Wendler-master File: CustomObjectAnimator.java View source code |
/**
* Animate a shaking factor to indicate something is wrong.
*/
public static ObjectAnimator nope(View view) {
int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f));
return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500);
}Example 16
| Project: xr-master File: TriangleSkewSpinIndicator.java View source code |
@Override
public List<Animator> createAnimation() {
List<Animator> animators = new ArrayList<>();
PropertyValuesHolder rotation5 = PropertyValuesHolder.ofFloat("rotationX", 0, 180, 180, 0, 0);
PropertyValuesHolder rotation6 = PropertyValuesHolder.ofFloat("rotationY", 0, 0, 180, 180, 0);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6, rotation5);
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(2500);
animator.start();
animators.add(animator);
return animators;
}Example 17
| Project: XRecyclerView-master File: TriangleSkewSpinIndicator.java View source code |
@Override
public List<Animator> createAnimation() {
List<Animator> animators = new ArrayList<>();
PropertyValuesHolder rotation5 = PropertyValuesHolder.ofFloat("rotationX", 0, 180, 180, 0, 0);
PropertyValuesHolder rotation6 = PropertyValuesHolder.ofFloat("rotationY", 0, 0, 180, 180, 0);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6, rotation5);
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(2500);
animator.start();
animators.add(animator);
return animators;
}Example 18
| Project: CloudReader-master File: Instrument.java View source code |
public void reset(View view, long duration) {
if (view == null) {
return;
}
view.clearAnimation();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
android.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
} else {
com.nineoldandroids.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
}
}Example 19
| Project: SlidingLayout-master File: Instrument.java View source code |
public void reset(View view, long duration) {
if (view == null) {
return;
}
view.clearAnimation();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
android.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
} else {
com.nineoldandroids.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
}
}Example 20
| Project: Android-Studio-Project-master File: PActivity.java View source code |
@Override
public void setContentView() {
setContentView(R.layout.pending_layout);
mTestImage = (ImageView) findViewById(R.id.iv_anim);
x = mTestImage.getX();
ObjectAnimator animator = ObjectAnimator.ofFloat(mTestImage, "scaleY", 1.0f, 2.0f);
ObjectAnimator animator1 = ObjectAnimator.ofFloat(mTestImage, "x", 800);
animator.setDuration(500);
AnimatorSet set = new AnimatorSet();
set.playSequentially(animator, animator1);
set.start();
}Example 21
| Project: android-TNRAnimationHelper-master File: ShakeAnimation.java View source code |
public void start() {
if (view == null)
throw new NullPointerException("View cant be null!");
final ObjectAnimator imageViewObjectAnimator = ObjectAnimator.ofFloat(view, "translationX", 0, 25, -25, 25, -25, 15, -15, 6, -6, 0);
imageViewObjectAnimator.setDuration(duration);
imageViewObjectAnimator.setRepeatMode(repeatMode);
imageViewObjectAnimator.setRepeatCount(repeatCount);
imageViewObjectAnimator.setInterpolator(new LinearInterpolator());
imageViewObjectAnimator.start();
}Example 22
| Project: AndroidSkinAnimator-master File: TranslationAlphaHideAnimator2.java View source code |
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("translationY", -view.getHeight()), PropertyValuesHolder.ofFloat("translationX", view.getWidth()), PropertyValuesHolder.ofFloat("rotation", 270), PropertyValuesHolder.ofFloat("scaleX", 0), PropertyValuesHolder.ofFloat("scaleY", 0));
animator.setDuration(5 * PRE_DURATION);
animator.setInterpolator(new LinearInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
resetView(view);
if (action != null) {
action.action();
}
}
});
return this;
}Example 23
| Project: Anime-se-master File: ObjectAnimatorActivity.java View source code |
@OnClick(R.id.button)
public void onClick(View v) {
image.setImageResource(R.drawable.heart_checked);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(image, "scaleX", 1f, 1.3f);
scaleX.setInterpolator(sAccelerate);
scaleX.setRepeatCount(1);
scaleX.setRepeatMode(ValueAnimator.REVERSE);
scaleX.setDuration((long) (180));
ObjectAnimator scaleY = ObjectAnimator.ofFloat(image, "scaleY", 1f, 1.3f);
scaleY.setInterpolator(sAccelerate);
scaleY.setRepeatCount(1);
scaleY.setRepeatMode(ValueAnimator.REVERSE);
scaleY.setDuration((long) (180));
AnimatorSet set1 = new AnimatorSet();
set1.playTogether(scaleX, scaleY);
AnimatorSet set2 = new AnimatorSet();
set2.playTogether(scaleX, scaleY);
AnimatorSet set = new AnimatorSet();
set.playSequentially(set1, set2);
set.start();
}Example 24
| Project: BetaSeries-master File: LoginViewController.java View source code |
private void animateDisapear(final ImageView imageView, final int delaySwitch) {
try {
ObjectAnimator disapear = ObjectAnimator.ofFloat(imageView, "alpha", 1, 0);
disapear.setStartDelay(delaySwitch);
disapear.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animateAppear(imageView, delaySwitch);
}
});
disapear.start();
} catch (Exception e) {
Log.d(TAG, e.getLocalizedMessage(), e);
}
}Example 25
| Project: blur-master File: MainActivity.java View source code |
private void init() {
this.findViewById(R.id.tv_blur).setOnClickListener(getOnClickListener());
this.findViewById(R.id.tv_blur_view).setOnClickListener(getOnClickListener());
BlurMaskRelativeLayout blurLayout = (BlurMaskRelativeLayout) this.findViewById(R.id.blur_container);
blurLayout.blurRadius(25);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(blurLayout, View.ALPHA, 0, 1f);
alphaAnimator.setDuration(2000);
alphaAnimator.start();
}Example 26
| Project: Carbon-master File: AnimatorsCompat.java View source code |
public static void setAutoCancel(final ObjectAnimator animator) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { for (WeakReference<ObjectAnimator> wa : sRunningAnimators) { ObjectAnimator a = wa.get(); if (a == null) { continue; } if (hasSameTargetAndProperties(animator, a)) { a.cancel(); } } } }); }
Example 27
| Project: cogitolearning-examples-master File: PropertyAnimation09.java View source code |
@Override
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.property_animations09);
if (android.os.Build.VERSION.SDK_INT >= 19) {
ImageView someImage = (ImageView) findViewById(R.id.some_image);
ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(someImage, "rotation", 0, 360);
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(5);
rotateAnim.setRepeatMode(ObjectAnimator.RESTART);
fpsText = (TextView) findViewById(R.id.fps_text);
FpsTimeListener listener = new FpsTimeListener(fpsText);
final TimeAnimator timeAnim = new TimeAnimator();
timeAnim.setTimeListener(listener);
anim = new AnimatorSet();
anim.play(rotateAnim).with(timeAnim);
rotateAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
timeAnim.end();
}
});
}
}Example 28
| Project: Conductor-master File: VerticalChangeHandler.java View source code |
@Override
@NonNull
protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) {
AnimatorSet animator = new AnimatorSet();
List<Animator> viewAnimators = new ArrayList<>();
if (isPush && to != null) {
viewAnimators.add(ObjectAnimator.ofFloat(to, View.TRANSLATION_Y, to.getHeight(), 0));
} else if (!isPush && from != null) {
viewAnimators.add(ObjectAnimator.ofFloat(from, View.TRANSLATION_Y, from.getHeight()));
}
animator.playTogether(viewAnimators);
return animator;
}Example 29
| Project: Depth-master File: ExitAnimation.java View source code |
@Override
public void prepareAnimators(DepthRelativeLayout target, int index, int animationDelay) {
final TimeInterpolator interpolator = new ExpoIn();
final float finalTranslationY = exitConfiguration.getFinalYPercent() * target.getResources().getDisplayMetrics().heightPixels;
final float finalTranslationX = exitConfiguration.getFinalXPercent() * target.getResources().getDisplayMetrics().widthPixels;
final long totalDuration = exitConfiguration.getDuration();
final ObjectAnimator translationY2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, finalTranslationY);
translationY2.setDuration(totalDuration);
//translationY2.setInterpolator(new AccelerateInterpolator());
translationY2.setInterpolator(interpolator);
translationY2.setStartDelay(animationDelay);
attachListener(translationY2);
add(translationY2);
final ObjectAnimator translationX2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, finalTranslationX);
translationX2.setDuration(totalDuration);
translationX2.setInterpolator(interpolator);
translationX2.setStartDelay(animationDelay);
add(translationX2);
}Example 30
| Project: Douya-master File: CrossfadeText.java View source code |
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
TextView view = (TextView) startValues.view;
CharSequence startText = (CharSequence) startValues.values.get(PROPNAME_TEXT);
CharSequence endText = (CharSequence) endValues.values.get(PROPNAME_TEXT);
view.setText(startText);
ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0, 1);
AnimatorListener listener = new AnimatorListener(view, endText);
animator.addListener(listener);
animator.addUpdateListener(listener);
return animator;
}Example 31
| Project: DroidCon-master File: Pop.java View source code |
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
view.setScaleX(0f);
view.setScaleY(0f);
PropertyValuesHolder[] pvh = new PropertyValuesHolder[2];
pvh[0] = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f);
pvh[1] = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f);
ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(view, pvh);
anim.setInterpolator(new OvershootInterpolator());
return anim;
}Example 32
| Project: DroidGraph-master File: RotatingCube.java View source code |
private void createAnimations() {
ObjectAnimator groupAnim = ObjectAnimator.ofFloat(this, "rotateZ", 0, 360);
groupAnim.setDuration(5000);
groupAnim.setInterpolator(new LinearInterpolator());
groupAnim.setRepeatCount(ObjectAnimator.INFINITE);
groupAnim.start();
ObjectAnimator one = ObjectAnimator.ofFloat(cubeOne, "scaleX", 1, 4);
one.setDuration(1000);
one.setRepeatCount(ObjectAnimator.INFINITE);
one.setRepeatMode(ObjectAnimator.REVERSE);
one.setInterpolator(new LinearInterpolator());
one.setStartDelay(0);
one.start();
ObjectAnimator three = ObjectAnimator.ofFloat(cubeTwo, "scaleY", 4, 1);
three.setDuration(1000);
three.setRepeatMode(ObjectAnimator.REVERSE);
three.setRepeatCount(ObjectAnimator.INFINITE);
three.setInterpolator(new LinearInterpolator());
three.start();
}Example 33
| Project: FlyRefresh-master File: SampleItemAnimator.java View source code |
@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
View target = holder.itemView;
View icon = target.findViewById(R.id.icon);
Animator swing = ObjectAnimator.ofFloat(icon, "rotationX", 45, 0);
swing.setInterpolator(new OvershootInterpolator(5));
View right = holder.itemView.findViewById(R.id.right);
Animator rotateIn = ObjectAnimator.ofFloat(right, "rotationY", 90, 0);
rotateIn.setInterpolator(new DecelerateInterpolator());
AnimatorSet animator = new AnimatorSet();
animator.setDuration(getAddDuration());
animator.playTogether(swing, rotateIn);
animator.start();
}Example 34
| Project: GanHuoIO-master File: SplashActivity.java View source code |
@Override
protected void setUpView() {
ObjectAnimator rotate = ObjectAnimator.ofFloat($(R.id.iv_logo), "rotationY", 180, 360);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(rotate);
animatorSet.setDuration(2000);
animatorSet.start();
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
});
}Example 35
| Project: GlassTunes-master File: ConfirmationActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_confirm);
((TextView) findViewById(R.id.text)).setText(getIntent().getStringExtra(EXTRA_TEXT));
ObjectAnimator animator = ObjectAnimator.ofInt(((ProgressBar) findViewById(R.id.progress)), "progress", 100).setDuration(1000);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
try {
if (getIntent().hasExtra(EXTRA_FOLLOW_ON_INTENT)) {
((PendingIntent) getIntent().getParcelableExtra(EXTRA_FOLLOW_ON_INTENT)).send();
}
} catch (CanceledException e) {
e.printStackTrace();
}
finish();
}
});
animator.start();
}Example 36
| Project: JianShuApp-master File: LoadingTextView.java View source code |
private void init() {
final int max = 9, middle = 4;
final String dot = "•";
mAnim = ValueAnimator.ofInt(0, max);
mAnim.setRepeatCount(ObjectAnimator.INFINITE);
mAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
String text;
int value = (Integer) valueAnimator.getAnimatedValue();
if (value <= middle) {
text = new String(new char[value + 1]).replace("\0", dot) + new String(new char[middle - value]).replace("\0", " ");
} else {
text = new String(new char[value - middle]).replace("\0", " ") + new String(new char[max - value]).replace("\0", dot);
}
setText(text);
}
});
mAnim.setDuration(max * 300);
}Example 37
| Project: Klyph-master File: GoogleCardStyleAdapter.java View source code |
@Override
public Animator[] getAnimators(ViewGroup parent, View view) {
ObjectAnimator translationY = ObjectAnimator.ofFloat(view, "translationY", 300, 0);
translationY.setInterpolator(new DecelerateInterpolator());
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 1f);
scaleX.setInterpolator(new DecelerateInterpolator());
//ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", mScaleFrom, 1f);
return new ObjectAnimator[] { translationY, /*, scaleY*/
scaleX };
}Example 38
| Project: LiquidButton-master File: BaseController.java View source code |
Animator getBaseAnimator(long duration, TimeInterpolator interpolator) {
ObjectAnimator animator = ObjectAnimator.ofFloat(this, "render", 0.0f, 1.0f);
animator.setDuration(duration);
animator.setInterpolator(interpolator);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
reset();
}
});
return animator;
}Example 39
| Project: Mortar-architect-master File: LateralViewTransition.java View source code |
@Override
public void transition(View enterView, View exitView, ViewTransitionDirection direction, AnimatorSet set) {
config.configure(set);
if (direction == ViewTransitionDirection.FORWARD || direction == ViewTransitionDirection.REPLACE) {
set.play(ObjectAnimator.ofFloat(enterView, View.TRANSLATION_X, enterView.getWidth(), 0));
set.play(ObjectAnimator.ofFloat(exitView, View.TRANSLATION_X, 0, -exitView.getWidth()));
} else {
set.play(ObjectAnimator.ofFloat(enterView, View.TRANSLATION_X, -enterView.getWidth(), 0));
set.play(ObjectAnimator.ofFloat(exitView, View.TRANSLATION_X, 0, exitView.getWidth()));
}
}Example 40
| Project: Mysplash-master File: AutoHideInkPageIndicator.java View source code |
public void setDisplayState(boolean show) {
if (dismissAnimator != null) {
dismissAnimator.cancel();
}
if (show) {
if (showAnimator != null) {
showAnimator.cancel();
}
showAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), 0.7F).setDuration(100);
showAnimator.start();
} else {
dismissAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), 0).setDuration(200);
dismissAnimator.setStartDelay(600);
dismissAnimator.start();
}
}Example 41
| Project: RecyclerViewAnimator-master File: ShakeIn.java View source code |
@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
ViewCompat.animate(holder.itemView).cancel();
ObjectAnimator objectAnimatorAnimator = ObjectAnimator.ofFloat(holder.itemView, "translationX", -ViewUtils.getScreenWidth(), -ViewUtils.getScreenWidth() * 3f / 4f, -ViewUtils.getScreenWidth() / 2f, -ViewUtils.getScreenWidth() / 4f, 0, 25, -25, 25, -25, 15, -15, 6, -6, 0);
objectAnimatorAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
animator.dispatchAddFinished(holder);
animator.mAddAnimations.remove(holder);
animator.dispatchFinishedWhenDone();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
objectAnimatorAnimator.setStartDelay(mDelay * mDelayCount);
objectAnimatorAnimator.setDuration(animator.getAddDuration());
objectAnimatorAnimator.start();
animator.mAddAnimations.add(holder);
}Example 42
| Project: RippleDrawable-master File: AnimatorsCompat.java View source code |
private static boolean hasSameTargetAndProperties(ObjectAnimator self, @Nullable Animator anim) { if (anim instanceof ObjectAnimator) { PropertyValuesHolder[] theirValues = ((ObjectAnimator) anim).getValues(); PropertyValuesHolder[] selfValues = self.getValues(); if (((ObjectAnimator) anim).getTarget() == self.getTarget() && selfValues.length == theirValues.length) { final int length = selfValues.length; for (int i = 0; i < length; ++i) { PropertyValuesHolder pvhMine = selfValues[i]; PropertyValuesHolder pvhTheirs = theirValues[i]; if (pvhMine.getPropertyName() == null || !pvhMine.getPropertyName().equals(pvhTheirs.getPropertyName())) { return false; } } return true; } } return false; }
Example 43
| Project: robolectric-master File: ShadowObjectAnimatorTest.java View source code |
@Test
public void start_shouldRunAnimation() {
final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4);
Robolectric.getForegroundThreadScheduler().pause();
animator.setDuration(1000);
animator.addListener(listener);
animator.start();
verify(listener).onAnimationStart(animator);
assertThat(target.getTransparency()).isEqualTo(0);
Robolectric.flushForegroundThreadScheduler();
verify(listener).onAnimationEnd(animator);
assertThat(target.getTransparency()).isEqualTo(4);
}Example 44
| Project: scoop-master File: VeritcalSlideTransition.java View source code |
private Animator createAnimator(View from, View to) {
int fromTranslation = isUpward ? -from.getHeight() : from.getHeight();
int toTranslation = isUpward ? to.getHeight() : -to.getHeight();
AnimatorSet set = new AnimatorSet();
set.play(ObjectAnimator.ofFloat(from, View.TRANSLATION_Y, fromTranslation));
set.play(ObjectAnimator.ofFloat(to, View.TRANSLATION_Y, toTranslation, 0));
return set;
}Example 45
| Project: SearchView-master File: SearchArrowDrawable.java View source code |
void animate(float state, int duration) {
ObjectAnimator anim;
if (state == STATE_ARROW) {
anim = ObjectAnimator.ofFloat(this, PROGRESS, STATE_HAMBURGER, state);
} else {
anim = ObjectAnimator.ofFloat(this, PROGRESS, STATE_ARROW, state);
}
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.setDuration(duration);
anim.start();
}Example 46
| Project: shuttle-master File: ViewUtils.java View source code |
public static void fadeOut(View view, @Nullable Action0 completion) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f).setDuration(250);
objectAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
objectAnimator.removeAllListeners();
if (completion != null) {
completion.call();
}
}
});
objectAnimator.start();
}Example 47
| Project: spikes-master File: RainDropEffect.java View source code |
@Override
public void animateParticle(View particleView, int parentWidth, int parentHeight) {
float x = RANDOM.nextFloat() * parentWidth;
particleView.setX(x);
ObjectAnimator animator = ObjectAnimator.ofFloat(particleView, "y", 0, parentHeight);
animator.setDuration(FALL_DURATION + RANDOM.nextInt(250));
animator.setInterpolator(INTERPOLATOR);
animator.setRepeatMode(ValueAnimator.RESTART);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.start();
animators.add(animator);
}Example 48
| Project: SwipePlaybarDemo-master File: PlaybarPagerTransformer.java View source code |
@Override
public void transformPage(View page, float position) {
for (ViewPager.PageTransformer transformer : mTransformers) {
transformer.transformPage(page, position);
}
//处�图片旋转
StopWatch.log("page: " + page + ", pos: " + position);
if (position == 0) {
ObjectAnimator animator = (ObjectAnimator) page.getTag(R.id.tag_animator);
if (animator != null) {
animator.start();
}
} else if (position == -1 || position == -2 || position == 1) {
ObjectAnimator animator = (ObjectAnimator) page.getTag(R.id.tag_animator);
if (animator != null) {
animator.end();
}
}
}Example 49
| Project: TransitionHelper-master File: NoneShowMethod.java View source code |
@Override
public void loadCopyView(InfoBean bean, ImageView copyView) {
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(copyView, "rotation", 0, 180), ObjectAnimator.ofFloat(copyView, "scaleX", 1, 0), ObjectAnimator.ofFloat(copyView, "scaleY", 1, 0));
set.setInterpolator(new AccelerateInterpolator());
set.setDuration(duration / 4 * 5).start();
}Example 50
| Project: TransitionPlayer-master File: ChangeAlpha.java View source code |
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
}
final View view = endValues.view;
float startAlpha = (Float) startValues.values.get(PROPNAME_ALPHA);
float endAlpha = (Float) endValues.values.get(PROPNAME_ALPHA);
if (startAlpha != endAlpha) {
view.setAlpha(startAlpha);
return ObjectAnimator.ofFloat(view, "alpha", startAlpha, endAlpha);
}
return null;
}Example 51
| Project: TryPro-master File: WelActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wel_act);
ButterKnife.inject(this);
ObjectAnimator animator = new ObjectAnimator().ofFloat(welImg, "scaleY", 1f, 2f);
ObjectAnimator animator1 = new ObjectAnimator().ofFloat(welImg, "scaleX", 1f, 2f);
ObjectAnimator animator2 = new ObjectAnimator().ofFloat(welImg, "alpha", 1f, 0f);
AnimatorSet set = new AnimatorSet();
set.playTogether(animator, animator1, animator2);
set.setDuration(5000);
set.start();
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
finish();
}
});
}Example 52
| Project: Weibo-Material-master File: ObjectAnimatorUtils.java View source code |
/**
* 动�改�一个View的属性值
*
* @param view
* @param attr
* @param value
*/
public static void changeAttrValue(final View view, String attr, int value, int duration, final OnAttrChangedCallback callback) {
ObjectAnimator oa = null;
oa = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofInt(attr, value));
oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
ViewGroup.LayoutParams params = callback.onAttrValueChanged((ViewGroup.LayoutParams) view.getLayoutParams(), value);
// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
// params.height = height;
// Logger.e(height);
view.setLayoutParams(params);
}
});
oa.setDuration(duration);
oa.start();
}Example 53
| Project: WordPress-Android-master File: FadeInNetworkImageView.java View source code |
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
if (getContext() == null)
return;
int duration = getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
// use faster property animation if device supports it
ObjectAnimator alpha = ObjectAnimator.ofFloat(this, View.ALPHA, 0.25f, 1f);
alpha.setDuration(duration);
alpha.start();
}Example 54
| Project: XDroidAnimation-master File: AlphaAnimation.java View source code |
@Override
public AnimatorSet createAnimatorSet() {
targetView.setAlpha(0f);
targetView.setVisibility(View.VISIBLE);
AnimatorSet fadeSet = new AnimatorSet();
fadeSet.play(ObjectAnimator.ofFloat(targetView, View.ALPHA, values));
fadeSet.setInterpolator(interpolator);
fadeSet.setDuration(duration);
if (listener != null) {
fadeSet.addListener(listener);
}
return fadeSet;
}Example 55
| Project: Carpaccio-master File: AnimationViewController.java View source code |
protected static void animate(View view, String parameter, int valueStart, int valueEnd, long duration, String easing) {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
android.animation.ObjectAnimator objectAnimator = android.animation.ObjectAnimator.ofFloat(view, parameter, valueStart, valueEnd).setDuration(duration);
BaseInterpolator interpolator = stringToInterpolator(easing);
if (interpolator != null)
objectAnimator.setInterpolator(interpolator);
objectAnimator.start();
} else {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, parameter, valueStart, valueEnd).setDuration(duration);
BaseInterpolator interpolator = stringToInterpolator(easing);
if (interpolator != null)
objectAnimator.setInterpolator(interpolator);
objectAnimator.start();
}
}Example 56
| Project: 9GAG-master File: Titanic.java View source code |
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}Example 57
| Project: ActivityOptionsICS-master File: SceneFade.java View source code |
public void playScreenAnims(final boolean isEnter) {
float fromAlpha, toAlpha;
if (isEnter) {
fromAlpha = 0f;
toAlpha = 1f;
} else {
fromAlpha = 1f;
toAlpha = 0f;
}
// TODO 自动生æˆ?çš„æ–¹æ³•å˜æ ¹
AnimatorSet set = new AnimatorSet();
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(getSceneRoot(), "alpha", fromAlpha, toAlpha);
set.addListener(new TransitionAnimsListener() {
@Override
public void onAnimationEnd(Animator animator) {
// TODO 自动生æˆ?çš„æ–¹æ³•å˜æ ¹
super.onAnimationEnd(animator);
if (isEnter) {
enterAnimsEnd();
} else {
exitAnimsEnd();
}
}
});
set.play(alphaAnim);
set.setDuration(getAnimsDuration());
set.setStartDelay(getAnimsStartDelay());
set.setInterpolator(getAnimsInterpolator());
set.start();
}Example 58
| Project: android-15-master File: Animated3dActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView view = new ImageView(this);
view.setImageResource(R.drawable.large_photo);
setContentView(view, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
animator.setDuration(4000);
animator.setRepeatCount(ObjectAnimator.INFINITE);
animator.setRepeatMode(ObjectAnimator.REVERSE);
animator.start();
}Example 59
| Project: android-demos-master File: VisibilityController.java View source code |
boolean setVisible(final boolean visible, boolean animated) {
if (isVisible() == visible) {
return false;
}
mVisible = visible;
if (animated) {
float toAlpha = visible ? 1.0f : 0.0f;
ObjectAnimator mAnimator = ObjectAnimator.ofFloat(mView, "Alpha", 1 - toAlpha, toAlpha);
mAnimator.setDuration(mAnimationDuration).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
if (visible) {
setViewVisible(true);
}
}
@Override
public void onAnimationEnd(Animator animator) {
if (!visible) {
setViewVisible(false);
}
}
});
mAnimator.start();
} else {
setViewVisible(visible);
}
return true;
}Example 60
| Project: android-Interpolator-master File: InterpolatorFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the fragment_animation layout
View v = inflater.inflate(R.layout.interpolator_fragment, container, false);
// Set up the 'animate' button, when it is clicked the view is animated with the options
// selected: the Interpolator, duration and animation path
Button button = (Button) v.findViewById(R.id.animateButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Interpolator selected in the spinner
Interpolator interpolator = mInterpolators[mInterpolatorSpinner.getSelectedItemPosition()];
// Duration selected in SeekBar
long duration = mDurationSeekbar.getProgress();
// Animation path is based on whether animating in or out
Path path = mIsOut ? mPathIn : mPathOut;
// Log animation details
Log.i(TAG, String.format("Starting animation: [%d ms, %s, %s]", duration, (String) mInterpolatorSpinner.getSelectedItem(), ((mIsOut) ? "Out (growing)" : "In (shrinking)")));
// Start the animation with the selected options
startAnimation(interpolator, duration, path);
// Toggle direction of animation (path)
mIsOut = !mIsOut;
}
});
// Get the label to display the selected duration
mDurationLabel = (TextView) v.findViewById(R.id.durationLabel);
// Initialize Interpolators programmatically by loading them from their XML definitions
// provided by the framework.
mInterpolators = new Interpolator[] { new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.linear), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.fast_out_linear_in), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.fast_out_slow_in), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.linear_out_slow_in) };
// Load names of interpolators from a resource
String[] interpolatorNames = getResources().getStringArray(R.array.interpolator_names);
// Set up the Spinner with the names of interpolators
mInterpolatorSpinner = (Spinner) v.findViewById(R.id.interpolatorSpinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, interpolatorNames);
mInterpolatorSpinner.setAdapter(spinnerAdapter);
// Set up SeekBar that defines the duration of the animation
mDurationSeekbar = (SeekBar) v.findViewById(R.id.durationSeek);
// Register listener to update the text label when the SeekBar value is updated
mDurationSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
mDurationLabel.setText(getResources().getString(R.string.animation_duration, i));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Set initial progress to trigger SeekBarChangeListener and update UI
mDurationSeekbar.setProgress(INITIAL_DURATION_MS);
// Get the view that will be animated
mView = v.findViewById(R.id.square);
// The following Path definitions are used by the ObjectAnimator to scale the view.
// Path for 'in' animation: growing from 20% to 100%
mPathIn = new Path();
mPathIn.moveTo(0.2f, 0.2f);
mPathIn.lineTo(1f, 1f);
// Path for 'out' animation: shrinking from 100% to 20%
mPathOut = new Path();
mPathOut.moveTo(1f, 1f);
mPathOut.lineTo(0.2f, 0.2f);
return v;
}Example 61
| Project: android-ripple-background-master File: MainActivity.java View source code |
private void foundDevice() {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(400);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
ArrayList<Animator> animatorList = new ArrayList<Animator>();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleX", 0f, 1.2f, 1f);
animatorList.add(scaleXAnimator);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleY", 0f, 1.2f, 1f);
animatorList.add(scaleYAnimator);
animatorSet.playTogether(animatorList);
foundDevice.setVisibility(View.VISIBLE);
animatorSet.start();
}Example 62
| Project: android-sdk-sources-for-api-level-23-master File: Animated3dActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView view = new ImageView(this);
view.setImageResource(R.drawable.large_photo);
setContentView(view, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
animator.setDuration(4000);
animator.setRepeatCount(ObjectAnimator.INFINITE);
animator.setRepeatMode(ObjectAnimator.REVERSE);
animator.start();
}Example 63
| Project: android-slideshow-widget-master File: ZoomTransitionFactory.java View source code |
//==============================================================================================
// INTERFACE IMPLEMENTATION: SlideTransitionFactory
//==
@Override
public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) {
target.setAlpha(0);
target.setScaleX(SCALE_FACTOR);
target.setScaleY(SCALE_FACTOR);
target.setTranslationX(0);
target.setTranslationY(0);
target.setRotationX(0);
target.setRotationY(0);
final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY, alpha);
animator.setDuration(getDuration());
animator.setInterpolator(getInterpolator());
return animator;
}Example 64
| Project: android2048-master File: Titanic.java View source code |
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}Example 65
| Project: AndroidFire-master File: SplashActivity.java View source code |
@Override
public void initView() {
SetTranslanteBar();
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0.3f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.3f, 1f);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.3f, 1f);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofPropertyValuesHolder(tvName, alpha, scaleX, scaleY);
ObjectAnimator objectAnimator2 = ObjectAnimator.ofPropertyValuesHolder(ivLogo, alpha, scaleX, scaleY);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(objectAnimator1, objectAnimator2);
animatorSet.setInterpolator(new AccelerateInterpolator());
animatorSet.setDuration(2000);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
MainActivity.startAction(SplashActivity.this);
finish();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
animatorSet.start();
}Example 66
| Project: AndroidLinkup-master File: ViewPathAnimator.java View source code |
/**
* 设置动画的起始点
*
* @param pathPoints
* 路径点
*/
public void animatePath(List<Point> pathPoints) {
if (pathPoints == null || pathPoints.size() == 0) {
return;
}
AnimatorPath path = new AnimatorPath();
path.moveTo(pathPoints.get(0).x, pathPoints.get(0).y);
for (int i = 1; i < pathPoints.size(); i++) {
path.lineTo(pathPoints.get(i).x, pathPoints.get(i).y);
}
ObjectAnimator anim = ObjectAnimator.ofObject(view, "location", new PathEvaluator(), path.getPoints().toArray());
anim.addListener(this);
anim.setDuration(duration);
anim.start();
}Example 67
| Project: AndroidPullToPong-master File: PongHeaderTransformer.java View source code |
@Override
public boolean showHeaderView() {
final boolean changeVis = mHeaderView.getVisibility() != View.VISIBLE;
if (changeVis) {
mPongPlayer.resetGamePieces();
mHeaderView.setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(mHeaderView, "alpha", 0f, 1f).setDuration(FADE_IN_OUT_DURATION).start();
}
return changeVis;
}Example 68
| Project: AndroidSharingPlatform-master File: ToolbarActivity.java View source code |
protected void hideOrShowToolbar() {
if (isHidden) {
/* ObjectAnimator.ofFloat(mAppBarLayout, "translationY", -mAppBarLayout.getHeight(), 0)
.start();*/
mAppBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
} else {
ObjectAnimator.ofFloat(mAppBarLayout, "translationY", 0, -mAppBarLayout.getHeight()).start();
}
isHidden = !isHidden;
}Example 69
| Project: AndroidStudyDemo-master File: SceneFade.java View source code |
public void playScreenAnims(final boolean isEnter) {
float fromAlpha, toAlpha;
if (isEnter) {
fromAlpha = 0f;
toAlpha = 1f;
} else {
fromAlpha = 1f;
toAlpha = 0f;
}
// TODO 自动生æˆ?çš„æ–¹æ³•å˜æ ¹
AnimatorSet set = new AnimatorSet();
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(getSceneRoot(), "alpha", fromAlpha, toAlpha);
set.addListener(new TransitionAnimsListener() {
@Override
public void onAnimationEnd(Animator animator) {
// TODO 自动生æˆ?çš„æ–¹æ³•å˜æ ¹
super.onAnimationEnd(animator);
if (isEnter) {
enterAnimsEnd();
} else {
exitAnimsEnd();
}
}
});
set.play(alphaAnim);
set.setDuration(getAnimsDuration());
set.setStartDelay(getAnimsStartDelay());
set.setInterpolator(getAnimsInterpolator());
set.start();
}Example 70
| Project: android_frameworks_base-master File: Animated3dActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView view = new ImageView(this);
view.setImageResource(R.drawable.large_photo);
setContentView(view, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
animator.setDuration(4000);
animator.setRepeatCount(ObjectAnimator.INFINITE);
animator.setRepeatMode(ObjectAnimator.REVERSE);
animator.start();
}Example 71
| Project: android_tv_metro-master File: TranslateAnimatorModel.java View source code |
@Override
public List<ValueAnimator> toAnimators() {
List<ValueAnimator> result = new ArrayList<ValueAnimator>();
if (mXDelta == 0 && mYDelta == 0) {
return result;
}
if (mXDelta != 0) {
float currentX = getAnimatorView().getX();
ObjectAnimator oa = ObjectAnimator.ofFloat(getAnimatorView(), "x", currentX + mXDelta);
assembleAnimator(oa);
result.add(oa);
}
if (mYDelta != 0) {
float currentY = getAnimatorView().getY();
ObjectAnimator oa = ObjectAnimator.ofFloat(getAnimatorView(), "y", currentY + mYDelta);
assembleAnimator(oa);
result.add(oa);
}
return result;
}Example 72
| Project: AnimeWallpaper-master File: AnimateUtils.java View source code |
public static void animateViewBitmap(@NonNull final ImageView root, Bitmap bitmap) {
if (bitmap == null && root.getDrawable() != null) {
ObjectAnimator.ofFloat(root, View.ALPHA, 1f, 0f).setDuration(ANIM_DORITION).start();
return;
}
Drawable[] layers = new Drawable[2];
layers[0] = root.getDrawable();
layers[1] = new BitmapDrawable(root.getResources(), bitmap);
if (layers[0] == null) {
//if null then alpha
root.setImageDrawable(layers[1]);
ObjectAnimator.ofFloat(root, View.ALPHA, 0.0f, 1.0f).setDuration(ANIM_DORITION).start();
return;
}
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
root.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(ANIM_DORITION);
}Example 73
| Project: Artbook-master File: CardIncomingAnimation.java View source code |
@Override
protected AnimatorSet getItemsAddedAnimation(List<FreeFlowItem> added) {
appearingSet = new AnimatorSet();
yAnims = new HashMap<View, PropertyValuesHolder>();
appearingSet.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
ArrayList<Animator> addedAnims = new ArrayList<Animator>();
for (FreeFlowItem proxy : added) {
proxy.view.setRotation(45f);
float y = proxy.view.getY();
proxy.view.setY(y + 2400f);
PropertyValuesHolder a1 = PropertyValuesHolder.ofFloat(View.ROTATION, 0);
PropertyValuesHolder a2 = PropertyValuesHolder.ofFloat(View.Y, y);
yAnims.put(proxy.view, a2);
ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(proxy.view, a1, a2);
anim.setDuration(MathUtils.randRange(800, 2000));
anim.setInterpolator(new EaseInOutQuintInterpolator());
addedAnims.add(anim);
}
appearingSet.playTogether(addedAnims);
return appearingSet;
}Example 74
| Project: BaseAnimation-master File: Titanic.java View source code |
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}Example 75
| Project: BasePopup-master File: SimpleAnimUtil.java View source code |
/**
* 从下方滑动上�
*/
public static AnimatorSet getDefaultSlideFromBottomAnimationSet(View mAnimaView) {
AnimatorSet set = null;
set = new AnimatorSet();
if (mAnimaView != null) {
set.playTogether(ObjectAnimator.ofFloat(mAnimaView, "translationY", 250, 0).setDuration(400), ObjectAnimator.ofFloat(mAnimaView, "alpha", 0.4f, 1).setDuration(250 * 3 / 2));
}
return set;
}Example 76
| Project: Bigbang-master File: KeyRelativeLayout.java View source code |
public void showEnterAnimation(Animator.AnimatorListener listener) {
originBg = getContext().getResources().getDrawable(R.drawable.borders);
animationBg = new ClipDrawable(originBg, Gravity.BOTTOM | Gravity.CLIP_VERTICAL, ClipDrawable.VERTICAL);
bgImage = new ImageView(this.getContext());
animationStep = 0;
animationBg.setLevel(animationStep);
bgImage.setImageDrawable(animationBg);
animationBg = (ClipDrawable) bgImage.getDrawable();
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewUtil.dp2px(90));
layoutParams.addRule(ALIGN_PARENT_BOTTOM);
addView(bgImage, 0, layoutParams);
ObjectAnimator animator = ObjectAnimator.ofInt(this, "animationStep", 0, 10000);
// animator.setDuration(300).addListener(listener);
animator.start();
}Example 77
| Project: BioWiki-master File: FadeInNetworkImageView.java View source code |
@SuppressLint("NewApi")
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
if (getContext() == null)
return;
int duration = getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
// use faster property animation if device supports it
if (SysUtils.isGteAndroid4()) {
ObjectAnimator alpha = ObjectAnimator.ofFloat(this, View.ALPHA, 0.25f, 1f);
alpha.setDuration(duration);
alpha.start();
} else {
AlphaAnimation animation = new AlphaAnimation(0.25f, 1f);
animation.setDuration(duration);
this.startAnimation(animation);
}
}Example 78
| Project: BlurLockView-master File: Dot.java View source code |
/**
* Set this dot to selected or not.
*
* @param isSelected Selected or not.
*/
public void setSelected(boolean isSelected) {
if (!(this.isSelected ^ isSelected))
return;
this.isSelected = isSelected;
if (isSelected) {
// change to selected
selected.setAlpha(0);
unselected.setAlpha(1);
if (selectedAnimator != null)
selectedAnimator.cancel();
if (unselectedAnimator != null)
unselectedAnimator.cancel();
selectedAnimator = ObjectAnimator.ofFloat(selected, "alpha", 0f, 1f);
selectedAnimator.setDuration(300);
selectedAnimator.start();
unselectedAnimator = ObjectAnimator.ofFloat(unselected, "alpha", 1f, 0f);
unselectedAnimator.setDuration(300);
unselectedAnimator.start();
} else {
// change to unselected
selected.setAlpha(1);
unselected.setAlpha(0);
if (selectedAnimator != null)
selectedAnimator.cancel();
if (unselectedAnimator != null)
unselectedAnimator.cancel();
selectedAnimator = ObjectAnimator.ofFloat(selected, "alpha", 1f, 0f);
selectedAnimator.setDuration(300);
selectedAnimator.start();
unselectedAnimator = ObjectAnimator.ofFloat(unselected, "alpha", 0f, 1f);
unselectedAnimator.setDuration(300);
unselectedAnimator.start();
}
}Example 79
| Project: CameraColorPicker-master File: Views.java View source code |
/**
* Credit goes to Cyril Mottier.
* https://plus.google.com/+CyrilMottier/posts/FABaJhRMCuy
*
* @param view the {@link View} to animate.
* @return an {@link ObjectAnimator} that will play a 'nope' animation.
*/
public static ObjectAnimator nopeAnimation(View view, int delta) {
PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f));
return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500);
}Example 80
| Project: CardStackView-master File: UpDownStackAnimatorAdapter.java View source code |
protected void itemExpandAnimatorSet(final CardStackView.ViewHolder viewHolder, int position) {
final View itemView = viewHolder.itemView;
itemView.clearAnimation();
ObjectAnimator oa = ObjectAnimator.ofFloat(itemView, View.Y, itemView.getY(), mCardStackView.getChildAt(0).getY());
mSet.play(oa);
int collapseShowItemCount = 0;
for (int i = 0; i < mCardStackView.getChildCount(); i++) {
int childTop;
if (i == mCardStackView.getSelectPosition())
continue;
final View child = mCardStackView.getChildAt(i);
child.clearAnimation();
if (i > mCardStackView.getSelectPosition() && collapseShowItemCount < mCardStackView.getNumBottomShow()) {
childTop = mCardStackView.getShowHeight() - getCollapseStartTop(collapseShowItemCount);
ObjectAnimator oAnim = ObjectAnimator.ofFloat(child, View.Y, child.getY(), childTop);
mSet.play(oAnim);
collapseShowItemCount++;
} else if (i < mCardStackView.getSelectPosition()) {
ObjectAnimator oAnim = ObjectAnimator.ofFloat(child, View.Y, child.getY(), mCardStackView.getChildAt(0).getY());
mSet.play(oAnim);
} else {
ObjectAnimator oAnim = ObjectAnimator.ofFloat(child, View.Y, child.getY(), mCardStackView.getShowHeight());
mSet.play(oAnim);
}
}
}Example 81
| Project: ColorTrackImageView-master File: SimpleUseActivity.java View source code |
@Override
public void run() {
Log.e("TAG", mColorTrackImageView.getWidth() + "");
anim = ObjectAnimator.ofFloat(mColorTrackImageView, "progress", 0, 1);
anim.setDuration(1000);
// anim.setRepeatMode(ValueAnimator.REVERSE);
anim.setRepeatCount(ValueAnimator.INFINITE);
anim.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
mColorTrackImageView.changeDirection();
if (mColorTrackImageView.getDirection() == ColorTrackImageView.DIRECTION_LEFT) {
mColorTrackImageView.setOriginColor(randomColor());
} else {
mColorTrackImageView.setChangeColor(randomColor());
}
}
private int randomColor() {
Random ran = new Random();
return Color.argb(255, ran.nextInt(255), ran.nextInt(255), ran.nextInt(255));
}
@Override
public void onAnimationEnd(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
anim.start();
}Example 82
| Project: commcare-master File: AudioPlaybackButton.java View source code |
@Override
protected void setupView(Context context) {
super.setupView(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
progressBar = (ProgressBar) findViewById(R.id.circular_progress_bar);
final int startPosition = 0;
final int progressBarMax = 500;
animation = ObjectAnimator.ofInt(progressBar, "progress", startPosition, progressBarMax);
}
}Example 83
| Project: coordinator-master File: AnimationLaunch.java View source code |
@Override
protected void onCreate(WelcomeCoordinatorLayout coordinator) {
objectAnimatorY = ObjectAnimator.ofFloat(getTargetView(), View.TRANSLATION_Y, 0, -getTargetView().getTop() - getTargetView().getHeight());
objectAnimatorY.setDuration(DURATION);
objectAnimatorY.setInterpolator(new LinearInterpolator());
objectAnimatorX = ObjectAnimator.ofFloat(getTargetView(), View.TRANSLATION_X, 0, coordinatorLayout.getWidth());
objectAnimatorX.setDuration(DURATION);
objectAnimatorX.setInterpolator(new LinearInterpolator());
}Example 84
| Project: CUT-IN-material-master File: AnimatorCutin.java View source code |
@SuppressLint("NewApi")
@Override
protected void start(Intent arg0, int arg1, int arg2) {
// in
ValueAnimator rotateIn = ObjectAnimator.ofFloat(mView, ImageView.ROTATION, 360f);
rotateIn.setDuration(1000);
DecelerateInterpolator di = new DecelerateInterpolator();
ValueAnimator scaleAnimX = ObjectAnimator.ofFloat(mView, ImageView.SCALE_X, 1.5f);
scaleAnimX.setDuration(1000);
scaleAnimX.setInterpolator(di);
ValueAnimator scaleAnimY = ObjectAnimator.ofFloat(mView, ImageView.SCALE_Y, 1.5f);
scaleAnimY.setDuration(1000);
scaleAnimY.setInterpolator(di);
// out
ValueAnimator rotateOut = ObjectAnimator.ofFloat(mView, ImageView.ROTATION, 0f);
rotateOut.setDuration(1000);
ValueAnimator fadeOut = ObjectAnimator.ofFloat(mView, ImageView.ALPHA, 0.0f);
fadeOut.setDuration(1000);
AnimatorSet tornado = new AnimatorSet();
tornado.play(rotateIn).with(scaleAnimX);
tornado.play(scaleAnimX).with(scaleAnimY);
tornado.play(rotateOut).after(scaleAnimX);
tornado.play(rotateOut).with(fadeOut);
tornado.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
finishCutin();
}
});
tornado.start();
}Example 85
| Project: DesignSupportLibraryDemo-master File: RecyclerViewAdapter.java View source code |
@Override
public void onClick(View v) {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20, 0);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mContext.startActivity(new Intent(mContext, DetailActivity.class));
}
});
animator.start();
}Example 86
| Project: DigCSDN-master File: LogoActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logo);
img_logo = (ImageView) findViewById(R.id.img_logo);
ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(img_logo, "alpha", 0f, 1f);
//�明度��动画
ObjectAnimator rotation = ObjectAnimator.ofFloat(img_logo, "rotation", 0f, 480f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(img_logo, "scaleX", 0, 1);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(img_logo, "scaleY", 0, 1);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(rotation).with(fadeInOut).with(scaleX).with(scaleY);
animatorSet.setDuration(2000);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LogoActivity.this, MainActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.push_left_in, R.anim.push_no);
finish();
}
}, 300);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}Example 87
| Project: diycode-master File: TextColorAnimExpectation.java View source code |
@Override
public Animator getAnimator(View viewToMove) {
if (viewToMove instanceof TextView) {
final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(viewToMove, "textColor", ((TextView) viewToMove).getCurrentTextColor(), textColor);
objectAnimator.setEvaluator(new ArgbEvaluator());
return objectAnimator;
} else {
return null;
}
}Example 88
| Project: ExpandableRecyclerview-master File: DepartmentItem.java View source code |
@Override
public void onExpansionToggled(boolean expanded) {
float start, target;
if (expanded) {
mExpand.setText("unexpand");
start = 0f;
target = 90f;
} else {
mExpand.setText("expand");
start = 90f;
target = 0f;
}
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mArrow, View.ROTATION, start, target);
objectAnimator.setDuration(300);
objectAnimator.start();
}Example 89
| Project: FineDay-master File: Titanic.java View source code |
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@SuppressLint("NewApi")
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}Example 90
| Project: firetweet-master File: IControlBarActivity.java View source code |
public void setControlBarVisibleAnimate(boolean visible) {
if (mControlAnimationDirection != 0)
return;
final ObjectAnimator animator;
final float offset = mActivity.getControlBarOffset();
if (visible) {
if (offset >= 1)
return;
animator = ObjectAnimator.ofFloat(mActivity, ControlBarOffsetProperty.SINGLETON, offset, 1);
} else {
if (offset <= 0)
return;
animator = ObjectAnimator.ofFloat(mActivity, ControlBarOffsetProperty.SINGLETON, offset, 0);
}
animator.setInterpolator(new DecelerateInterpolator());
animator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mControlAnimationDirection = 0;
}
@Override
public void onAnimationCancel(Animator animation) {
mControlAnimationDirection = 0;
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animator.setDuration(DURATION);
animator.start();
mControlAnimationDirection = visible ? 1 : -1;
}Example 91
| Project: FloatingView-master File: ScaleFloatingTransition.java View source code |
@Override
public void applyFloating(final YumFloating yumFloating) {
ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
alphaAnimator.setDuration(mDuration);
alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
yumFloating.setAlpha((Float) valueAnimator.getAnimatedValue());
}
});
alphaAnimator.start();
SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, mBounciness, mSpeed).reboundListener(new SimpleReboundListener() {
@Override
public void onReboundUpdate(double currentValue) {
yumFloating.setScaleX((float) currentValue);
yumFloating.setScaleY((float) currentValue);
}
}).start(yumFloating);
}Example 92
| Project: frameworks_base_disabled-master File: Animated3dActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView view = new ImageView(this);
view.setImageResource(R.drawable.large_photo);
setContentView(view, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
animator.setDuration(4000);
animator.setRepeatCount(ObjectAnimator.INFINITE);
animator.setRepeatMode(ObjectAnimator.REVERSE);
animator.start();
}Example 93
| Project: GifAssistant-master File: Titanic.java View source code |
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}Example 94
| Project: GitHubExplorer-master File: RecyclerViewAdapter.java View source code |
@Override
public void onClick(View v) {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20, 0);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mContext.startActivity(new Intent(mContext, DetailActivity.class));
}
});
animator.start();
}Example 95
| Project: glview-master File: RotateView1Activity.java View source code |
public View getContentView() {
FrameLayout fl = new FrameLayout(this);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, Gravity.CENTER);
LinearLayout l = new LinearLayout(this);
fl.addView(l, lp);
// LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(300, 300);
LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
ImageView iv = new ImageView(this);
// iv.setRotationX(30);
iv.setImageResource(R.drawable.bitmap1);
l.addView(iv, lp1);
iv = new ImageView(this);
// iv.setRotationX(30);
iv.setImageResource(R.drawable.bitmap1);
// l.addView(iv, lp1);
iv = new ImageView(this);
// iv.setRotationX(30);
iv.setImageResource(R.drawable.bitmap1);
// l.addView(iv, lp1);
ObjectAnimator animator = ObjectAnimator.ofFloat(l, "rotationX", 0, 1000);
animator.setDuration(5000);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setRepeatMode(ValueAnimator.REVERSE);
animator.start();
animator = ObjectAnimator.ofFloat(l, "rotationY", 0, 1000);
animator.setDuration(10000);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setRepeatMode(ValueAnimator.REVERSE);
// animator.start();
animator = ObjectAnimator.ofFloat(l, "scale", 1f, 0.3f);
animator.setDuration(3000);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setRepeatMode(ValueAnimator.REVERSE);
return fl;
}Example 96
| Project: googletv-android-samples-master File: VisibilityController.java View source code |
boolean setVisible(final boolean visible, boolean animated) {
if (isVisible() == visible) {
return false;
}
mVisible = visible;
if (animated) {
float toAlpha = visible ? 1.0f : 0.0f;
ObjectAnimator mAnimator = ObjectAnimator.ofFloat(mView, "Alpha", 1 - toAlpha, toAlpha);
mAnimator.setDuration(mAnimationDuration).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
if (visible) {
setViewVisible(true);
}
}
@Override
public void onAnimationEnd(Animator animator) {
if (!visible) {
setViewVisible(false);
}
}
});
mAnimator.start();
} else {
setViewVisible(visible);
}
return true;
}Example 97
| Project: GSoC-master File: AnimationHelper.java View source code |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static ObjectAnimator Nope(View view) { int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium); PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500); }
Example 98
| Project: Hacker-News-Android-master File: BaseFragment.java View source code |
protected void showProgress(boolean showProgress) {
if (getActivity() == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ObjectAnimator fadeIn = (ObjectAnimator) AnimatorInflater.loadAnimator(getActivity(), R.animator.fadein);
ObjectAnimator fadeOut = (ObjectAnimator) AnimatorInflater.loadAnimator(getActivity(), R.animator.fadeout);
if (showProgress) {
FadeListener fadeInListener = new FadeListener(mContainer, mProgressBar);
fadeIn.addListener(fadeInListener);
fadeIn.start();
} else {
FadeListener fadeOutListener = new FadeListener(mProgressBar, mContainer);
fadeOut.addListener(fadeOutListener);
fadeOut.start();
}
} else {
mProgressBar.setVisibility(showProgress ? View.VISIBLE : View.GONE);
mContainer.setVisibility(showProgress ? View.GONE : View.VISIBLE);
}
}Example 99
| Project: huabanDemo-master File: AnimatorUtils.java View source code |
//用�上 Fab有自己的��显示方法
public static AnimatorSet getScale(View target) {
final AnimatorSet set = new AnimatorSet();
ObjectAnimator animatorX = ObjectAnimator.ofFloat(target, View.SCALE_X, 1, 0, 1);
ObjectAnimator animatorY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 1, 0, 1);
set.setDuration(1000);
set.play(animatorX).with(animatorY);
set.setInterpolator(new FastOutSlowInInterpolator());
return set;
}Example 100
| Project: InfiniteRecyclerView-master File: SampleAdapter.java View source code |
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof LoadingViewHolder) {
LoadingViewHolder loadingViewHolder = (LoadingViewHolder) holder;
ObjectAnimator animator = ObjectAnimator.ofFloat(loadingViewHolder.loadingImage, "rotation", 0, 360);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(1000);
animator.start();
return;
} else {
((DummyViewHolder) holder).tv.setText(sampleData.get(position));
}
super.onBindViewHolder(holder, position);
}Example 101
| Project: itsnat_droid-master File: AttrDescView_widget_AdapterViewAnimator_inoutAnimation.java View source code |
@Override
public void setAttribute(View view, DOMAttr attr, AttrLayoutContext attrCtx) {
ObjectAnimator animator = (ObjectAnimator) getAnimator(attr.getResourceDesc(), attrCtx.getXMLInflaterContext());
AdapterViewAnimator adapterViewAnimator = (AdapterViewAnimator) view;
String value = attr.getName();
if ("inAnimation".equals(value)) {
if (animator == null)
animator = getDefaultInAnimation();
adapterViewAnimator.setInAnimation(animator);
} else if ("outAnimation".equals(value)) {
if (animator == null)
animator = getDefaultOutAnimation();
adapterViewAnimator.setOutAnimation(animator);
} else
throw MiscUtil.internalError();
}