本文整理汇总了Java中android.animation.ObjectAnimator类的典型用法代码示例。如果您正苦于以下问题:Java ObjectAnimator类的具体用法?Java ObjectAnimator怎么用?Java ObjectAnimator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectAnimator类属于android.animation包,在下文中一共展示了ObjectAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyBadgeState
import android.animation.ObjectAnimator; //导入依赖的package包/类
public void applyBadgeState(ItemInfo itemInfo, boolean animate) {
if (mIcon instanceof FastBitmapDrawable) {
boolean wasBadged = mBadgeInfo != null;
mBadgeInfo = mLauncher.getPopupDataProvider().getBadgeInfoForItem(itemInfo);
boolean isBadged = mBadgeInfo != null;
float newBadgeScale = isBadged ? 1f : 0;
mBadgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer;
if (wasBadged || isBadged) {
mBadgePalette = ((FastBitmapDrawable) mIcon).getIconPalette();
// Animate when a badge is first added or when it is removed.
if (animate && (wasBadged ^ isBadged) && isShown()) {
ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, newBadgeScale).start();
} else {
mBadgeScale = newBadgeScale;
invalidate();
}
}
}
}
示例2: closeDrawer
import android.animation.ObjectAnimator; //导入依赖的package包/类
public void closeDrawer(boolean fast) {
cancelCurrentAnimation();
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(this, "drawerPosition", 0)
);
animatorSet.setInterpolator(new DecelerateInterpolator());
if (fast) {
animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
} else {
animatorSet.setDuration(300);
}
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animator) {
onDrawerAnimationEnd(false);
}
});
animatorSet.start();
}
示例3: createShowItemAnimator
import android.animation.ObjectAnimator; //导入依赖的package包/类
private Animator createShowItemAnimator(View item) {
float dx = centerItem.getX() - item.getX();
float dy = centerItem.getY() - item.getY();
item.setScaleX(0f);
item.setScaleY(0f);
item.setTranslationX(dx);
item.setTranslationY(dy);
Animator anim = ObjectAnimator.ofPropertyValuesHolder(
item,
AnimatorUtils.scaleX(0f, 1f),
AnimatorUtils.scaleY(0f, 1f),
AnimatorUtils.translationX(dx, 0f),
AnimatorUtils.translationY(dy, 0f)
);
anim.setInterpolator(new DecelerateInterpolator());
anim.setDuration(50);
return anim;
}
示例4: testAnim
import android.animation.ObjectAnimator; //导入依赖的package包/类
@NonNull
private AnimatorSet testAnim(GiftFrameLayout giftFrameLayout) {
PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0, -50);
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.5f);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
animator.setStartDelay(0);
animator.setDuration(1500);
translationY = PropertyValuesHolder.ofFloat("translationY", -50, -100);
alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f, 0f);
ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
animator1.setStartDelay(0);
animator1.setDuration(1500);
// 复原
// ObjectAnimator fadeAnimator2 = GiftAnimationUtil.createFadeAnimator(giftFrameLayout, 0, 0, 0, 0);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(animator1).after(animator);
// animatorSet.play(fadeAnimator2).after(animator1);
animatorSet.start();
return animatorSet;
}
示例5: targetViewAnim
import android.animation.ObjectAnimator; //导入依赖的package包/类
/**
* 用于小圆点的放大缩小
* @param view
* @param type
*/
private void targetViewAnim(final View view, final int type){
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator scaleX = null;
ObjectAnimator scaleY = null;
ObjectAnimator alpha = null;
if (type == ANIM_OUT){
scaleX = ObjectAnimator.ofFloat(view,"scaleX",SCALE_MIN,mScale_max);
scaleY = ObjectAnimator.ofFloat(view,"scaleY",SCALE_MIN,mScale_max);
alpha = ObjectAnimator.ofFloat(view,"alpha",mAlpha_min,ALPHA_MAX);
animatorSet.setDuration(ANIM_OUT_TIME);
}else{
scaleX = ObjectAnimator.ofFloat(view,"scaleX",mScale_max,SCALE_MIN);
scaleY = ObjectAnimator.ofFloat(view,"scaleY",mScale_max,SCALE_MIN);
alpha = ObjectAnimator.ofFloat(view,"alpha",ALPHA_MAX,mAlpha_min);
animatorSet.setDuration(ANIM_IN_TIME);
}
animatorSet.play(scaleX).with(scaleY).with(alpha);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorSet.start();
}
示例6: initAnimator
import android.animation.ObjectAnimator; //导入依赖的package包/类
private void initAnimator() {
if (mObjectAnimator == null) {
mObjectAnimator = ObjectAnimator.ofInt(3, 6);
mObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
if (value != last) {
last = value;
factor = last / 10f;
L.e("call: onAnimationUpdate([animation])-> " + factor);
postInvalidate();
}
}
});
mObjectAnimator.setRepeatCount(ValueAnimator.INFINITE);
mObjectAnimator.setRepeatMode(ValueAnimator.REVERSE);
mObjectAnimator.setDuration(300);
mObjectAnimator.start();
}
}
示例7: showContent
import android.animation.ObjectAnimator; //导入依赖的package包/类
@Override public void showContent() {
if (adapter.getItemCount() == 0) {
if (isRestoringViewState()) {
emptyView.setVisibility(View.VISIBLE);
} else {
ObjectAnimator anim = ObjectAnimator.ofFloat(emptyView, "alpha", 0f, 1f).setDuration(300);
anim.setStartDelay(250);
anim.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
emptyView.setVisibility(View.VISIBLE);
}
});
anim.start();
}
} else {
emptyView.setVisibility(View.GONE);
}
super.showContent();
}
示例8: startSecondAnimation
import android.animation.ObjectAnimator; //导入依赖的package包/类
public void startSecondAnimation(View view) {
ObjectAnimator rotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 0f, 25f);
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mView1, "alpha", 0.5f, 1f);
ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mView1, "scaleX", 0.8f, 1f);
ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mView1, "scaleY", 0.8f, 1f);
ObjectAnimator translationYAnimation = ObjectAnimator.ofFloat(mView1, "translationY", -0.1f * mView1.getHeight(), 0f);
ObjectAnimator rerotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 25f, 0f);
rerotationXAnimation.setStartDelay(200);
ObjectAnimator translationYAnimation2 = ObjectAnimator.ofFloat(mView2, "translationY", 0, mView2.getHeight());
translationYAnimation2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mView2.setVisibility(View.INVISIBLE);
}
});
AnimatorSet as = new AnimatorSet();
as.playTogether(rotationXAnimation, alphaAnimation, scaleXAnimation, scaleYAnimation,
translationYAnimation,
rerotationXAnimation, translationYAnimation2);
as.setDuration(200);
as.start();
}
示例9: onDrawState
import android.animation.ObjectAnimator; //导入依赖的package包/类
@Override
public final void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
final int width = rv.getMeasuredWidth();
final int height = rv.getMeasuredHeight();
// Draw all of our content items
renderContent(numberOfContentItems, width, height, canvas, contentPaint);
// Setup and start animation, if possible
if (animateContentItems) {
if (anim == null) {
this.anim = ObjectAnimator.ofObject(contentPaint, "color", new ArgbEvaluator(),
Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
onInterceptAnimatorCreation(anim);
this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rv.invalidate();
}
});
this.anim.start();
}
}
}
示例10: runTestChangeAnimation
import android.animation.ObjectAnimator; //导入依赖的package包/类
/**
* Procedure meant to execute a change animation for the desired {@link RecyclerView.ViewHolder}.
* @param holder the {@link RecyclerView} item's {@link RecyclerView.ViewHolder}.
* @param itemView the {@link RecyclerView.ViewHolder}'s root view.
* @param listener the {@link GenericItemAnimator} instance orchestrating the animations.
* @return the resulting {@link AnimatorSet} for the {@link RecyclerView} item's {@link RecyclerView.ViewHolder}.
*/
public static AnimatorSet runTestChangeAnimation(@NonNull final RecyclerView.ViewHolder holder,
@NonNull final View itemView,
@NonNull final GenericItemAnimator listener) {
final ObjectAnimator oldTextRotate = ObjectAnimator.ofFloat(itemView, View.ROTATION_X, 0, 90);
final ObjectAnimator newTextRotate = ObjectAnimator.ofFloat(itemView, View.ROTATION_X, -90, 0);
final AnimatorSet textAnim = new AnimatorSet();
textAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(@NonNull final Animator animation) {
listener.onAnimationFinished(holder, CHANGE_ANIMATION_FINISHED);
}
});
textAnim.playSequentially(oldTextRotate, newTextRotate);
return textAnim;
}
示例11: hide
import android.animation.ObjectAnimator; //导入依赖的package包/类
/**
* 隐藏下面的菜单
*/
private void hide() {
rel.startAnimation(mHiddenAction);
rel.setVisibility(View.INVISIBLE);
mFloatingActionsMenu.startAnimation(mHiddenAction1);
mFloatingActionsMenu.setVisibility(View.INVISIBLE);
animatorHeadHide = ObjectAnimator.ofFloat(vvv, "translationY", 0, -headHight);
animatorHeadHide.setDuration(666);
animatorHeadHide.start();
animatorHeadHide.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Log.e("lllxxx",animation.getAnimatedValue()+"===");
linearParams.height = headHight+(int)((float)animation.getAnimatedValue());
head.setLayoutParams(linearParams);
}
});
}
示例12: alphaObjectAnimator
import android.animation.ObjectAnimator; //导入依赖的package包/类
protected ObjectAnimator alphaObjectAnimator(View view, final boolean fadeIn, long duration, boolean postBack) {
final ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", fadeIn ? new float[]{
0f, 1f} : new float[]{1f, 0f});
anim.setDuration(duration);
if (postBack) {
final WeakReference<View> wr = new WeakReference<>(view);
anim.addListener(new ManipulateAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
if (wr.get() != null) {
wr.get().setAlpha(fadeIn ? 0 : 1);
}
}
});
}
return anim;
}
示例13: startBeatsAnimation
import android.animation.ObjectAnimator; //导入依赖的package包/类
@UiThread public static void startBeatsAnimation(@NonNull View view) {
view.clearAnimation();
if (view.getAnimation() != null) {
view.getAnimation().cancel();
}
List<ObjectAnimator> animators = getBeats(view);
for (ObjectAnimator anim : animators) {
anim.setDuration(300).start();
anim.setInterpolator(interpolator);
}
}
示例14: initAnim
import android.animation.ObjectAnimator; //导入依赖的package包/类
private void initAnim() {
animationDrawable = new AnimationDrawable();
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100);
animationDrawable.setOneShot(true);
animationDrawable.setExitFadeDuration(300);
animationDrawable.setEnterFadeDuration(100);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f);
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f);
animatorSet = new AnimatorSet();
animatorSet.setDuration(300l);
animatorSet.playTogether(objectAnimator1, objectAnimator2);
objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f);
objectAnimator.setDuration(2000l);
}
示例15: closeStickersView
import android.animation.ObjectAnimator; //导入依赖的package包/类
private void closeStickersView() {
if (stickersView == null || stickersView.getVisibility() != VISIBLE) {
return;
}
pickingSticker = false;
Animator a = ObjectAnimator.ofFloat(stickersView, "alpha", 1.0f, 0.0f);
a.setDuration(200);
a.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animator) {
stickersView.setVisibility(GONE);
}
});
a.start();
undoItem.setVisibility(VISIBLE);
actionBar.setTitle(LocaleController.getString("PaintDraw", R.string.PaintDraw));
}