本文整理汇总了Java中android.animation.ObjectAnimator.setRepeatCount方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectAnimator.setRepeatCount方法的具体用法?Java ObjectAnimator.setRepeatCount怎么用?Java ObjectAnimator.setRepeatCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ObjectAnimator
的用法示例。
在下文中一共展示了ObjectAnimator.setRepeatCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: animateDisplayWave
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* 动画
*/
private void animateDisplayWave() {
if (left_WaveView != null && center_WaveView != null) {
left_WaveView.setAnimationCacheEnabled(false);
center_WaveView.setAnimationCacheEnabled(false);
ObjectAnimator transX_waveLeft = ObjectAnimator.ofFloat(left_WaveView, "translationX", 0, 1920);
ObjectAnimator transX_waveCenter = ObjectAnimator.ofFloat(center_WaveView, "translationX", 0, 1920);
transX_waveLeft.setRepeatMode(ValueAnimator.RESTART);
transX_waveLeft.setRepeatCount(Animation.INFINITE);
transX_waveCenter.setRepeatMode(ValueAnimator.RESTART);
transX_waveCenter.setRepeatCount(Animation.INFINITE);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(16000);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.playTogether(transX_waveLeft, transX_waveCenter);
animatorSet.start();
}
}
示例2: build
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* build a copy of given animator
*
* @return
*/
public Animator build() {
//这种方式clone出来的animator不能重复播放
/*final ObjectAnimator result = getAnimator().clone();//克隆一份
setupListeners(result);
result.setupStartValues();
return result;*/
final ObjectAnimator self = this.getAnimator();
final ObjectAnimator anim = new ObjectAnimator();
anim.setTarget(self.getTarget());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
anim.setAutoCancel(true);
}
if (self.getValues() != null) {
anim.setValues(self.getValues());
}
anim.setInterpolator(self.getInterpolator());
anim.setDuration(self.getDuration());
anim.setStartDelay(self.getStartDelay());
anim.setRepeatCount(self.getRepeatCount());
anim.setRepeatMode(self.getRepeatMode());
setupListeners(anim);
return anim;
}
示例3: createAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0.5f,1,0.5f);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
ObjectAnimator rotateAnim=ObjectAnimator.ofFloat(getTarget(),"rotation",0,180,360);
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(-1);
rotateAnim.start();
animators.add(scaleAnim);
animators.add(rotateAnim);
return animators;
}
示例4: generateAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private Animator generateAnimation() {
ObjectAnimator blink = ObjectAnimator.ofFloat(this, "waveScale", 0f, 1f);
blink.setDuration(priority);
if (playInterpolator != null) {
blink.setInterpolator(playInterpolator);
}
blink.setRepeatCount(Animation.INFINITE);
blink.setRepeatMode(Animation.INFINITE);
ObjectAnimator alphaAnimator = ObjectAnimator.ofInt(this, "alpha", 255, 0);
alphaAnimator.setDuration(priority);
if (alphaInterpolator != null) {
alphaAnimator.setInterpolator(alphaInterpolator);
}
alphaAnimator.setRepeatCount(Animation.INFINITE);
alphaAnimator.setRepeatMode(Animation.INFINITE);
animatorSet.playTogether(blink, alphaAnimator);
return animatorSet;
}
示例5: createAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationX",0,360);
ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6);
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(1500);
animator.start();
List<Animator> animators=new ArrayList<>();
animators.add(animator);
return animators;
}
示例6: animateAnimatorSetSample
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void animateAnimatorSetSample(ImageView target) {
// Set AnimatorList(Will set on AnimatorSet)
List<Animator> animatorList= new ArrayList<Animator>();
// alphaプロパティを0fから1fに変化させます
PropertyValuesHolder alphaAnimator = PropertyValuesHolder.ofFloat("alpha", minAlpha ,maxAlpha, minAlpha);
PropertyValuesHolder flipAnimator = PropertyValuesHolder.ofFloat(orientation, startAngle, endAngle);
ObjectAnimator translationAnimator =
ObjectAnimator.ofPropertyValuesHolder(target, alphaAnimator, flipAnimator);
translationAnimator.setDuration(duration);
translationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// // faster
// translationAnimator.setInterpolator(new AccelerateInterpolator());
// // slower
// translationAnimator.setInterpolator(new DecelerateInterpolator());
// // fast->slow->fast
// translationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// repeat translationAnimator
translationAnimator.setRepeatCount(ObjectAnimator.INFINITE);
// Set all animation to animatorList
animatorList.add(translationAnimator);
final AnimatorSet animatorSet = new AnimatorSet();
// Set animatorList to animatorSet
animatorSet.playSequentially(animatorList);
// Start Animation
animatorSet.start();
}
示例7: startAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
void startAnimation() {
// This variation uses an ObjectAnimator. The functionality is exactly the same as
// in Bouncer2, but this time the boilerplate code is greatly reduced because we
// tell ObjectAnimator to automatically animate the target object for us, so we no
// longer need to listen for frame updates and do that work ourselves.
ObjectAnimator anim = getObjectAnimator();
anim.setRepeatCount(ValueAnimator.INFINITE);
anim.setRepeatMode(ValueAnimator.REVERSE);
anim.setInterpolator(new AccelerateInterpolator());
anim.start();
}
示例8: ProgressBarView
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public ProgressBarView(ContainerType containerType, ViewGroup container,
XSharedPreferences prefs, ProgressBarController ctrl) {
super(container.getContext());
mContainerType = containerType;
mCtrl = ctrl;
mAnimated = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_ANIMATED, true);
mCentered = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_CENTERED, false);
mHeightPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_THICKNESS, 1),
getResources().getDisplayMetrics());
mEdgeMarginPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_MARGIN, 0),
getResources().getDisplayMetrics());
setScaleX(0f);
setBackgroundColor(Color.WHITE);
setVisibility(View.GONE);
container.addView(this);
mAnimator = new ObjectAnimator();
mAnimator.setTarget(this);
mAnimator.setInterpolator(new DecelerateInterpolator());
mAnimator.setDuration(ANIM_DURATION);
mAnimator.setRepeatCount(0);
}
示例9: setRepeatCount
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* 重复次数,负数标示无限
*
* @param repeatCount
* @return
*/
public UDAnimator setRepeatCount(int repeatCount) {
final ObjectAnimator animator = getAnimator();
if (animator != null) {
if (repeatCount >= 0) {
animator.setRepeatCount(repeatCount);
} else {
animator.setRepeatCount(ValueAnimator.INFINITE);
}
}
return this;
}
示例10: createLoadingAnimator
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private Animator createLoadingAnimator() {
ObjectAnimator rotation = ObjectAnimator
.ofFloat(mImgLoading, "rotation", 0, 360);
//RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotation.setRepeatCount(ObjectAnimator.INFINITE);
rotation.setRepeatMode(ObjectAnimator.RESTART);
rotation.setInterpolator(new LinearInterpolator());
rotation.setDuration(mLoadingTime);
return rotation;
}
示例11: createAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@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;
}
示例12: createAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@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;
}
示例13: init
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void init(final Context context, final AttributeSet attrs) {
if (isInEditMode())
return;
if (null == attrs) {
throw new IllegalArgumentException("Attributes should be provided to this view,");
}
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
rippleColor = typedArray.getColor(R.styleable.RippleBackground_rb_color, Color.parseColor("#0099CC"));
rippleStrokeWidth = typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDisplayMetrics().density * 4);
rippleRadius = typedArray.getDimension(R.styleable.RippleBackground_rb_radius, getResources().getDisplayMetrics().density * 60);
rippleDurationTime = typedArray.getInt(R.styleable.RippleBackground_rb_duration, DEFAULT_DURATION_TIME);
rippleAmount = typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT);
rippleScale = typedArray.getFloat(R.styleable.RippleBackground_rb_scale, DEFAULT_SCALE);
rippleType = typedArray.getInt(R.styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE);
typedArray.recycle();
rippleDelay = rippleDurationTime / rippleAmount;
paint = new Paint();
paint.setAntiAlias(true);
if (rippleType == DEFAULT_FILL_TYPE) {
rippleStrokeWidth = 0;
paint.setStyle(Paint.Style.FILL);
} else
paint.setStyle(Paint.Style.STROKE);
paint.setColor(rippleColor);
rippleParams = new LayoutParams((int) (2 * (rippleRadius + rippleStrokeWidth)), (int) (2 * (rippleRadius + rippleStrokeWidth)));
rippleParams.addRule(CENTER_IN_PARENT, TRUE);
animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorList = new ArrayList<Animator>();
for (int i = 0; i < rippleAmount; i++) {
RippleView rippleView = new RippleView(getContext());
addView(rippleView, rippleParams);
rippleViewList.add(rippleView);
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
scaleXAnimator.setStartDelay(i * rippleDelay);
scaleXAnimator.setDuration(rippleDurationTime);
animatorList.add(scaleXAnimator);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
scaleYAnimator.setStartDelay(i * rippleDelay);
scaleYAnimator.setDuration(rippleDurationTime);
animatorList.add(scaleYAnimator);
final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
alphaAnimator.setStartDelay(i * rippleDelay);
alphaAnimator.setDuration(rippleDurationTime);
animatorList.add(alphaAnimator);
}
animatorSet.playTogether(animatorList);
}
示例14: init
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void init(final Context context, final AttributeSet attrs) {
if (isInEditMode())
return;
if (null == attrs) {
throw new IllegalArgumentException("Attributes should be provided to this view,");
}
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
rippleColor=typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippelColor));
rippleStrokeWidth=typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDimension(R.dimen.rippleStrokeWidth));
rippleRadius=typedArray.getDimension(R.styleable.RippleBackground_rb_radius,getResources().getDimension(R.dimen.rippleRadius));
rippleDurationTime=typedArray.getInt(R.styleable.RippleBackground_rb_duration,DEFAULT_DURATION_TIME);
rippleAmount=typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount,DEFAULT_RIPPLE_COUNT);
rippleScale=typedArray.getFloat(R.styleable.RippleBackground_rb_scale,DEFAULT_SCALE);
rippleType=typedArray.getInt(R.styleable.RippleBackground_rb_type,DEFAULT_FILL_TYPE);
typedArray.recycle();
rippleDelay=rippleDurationTime/rippleAmount;
paint = new Paint();
paint.setAntiAlias(true);
if(rippleType==DEFAULT_FILL_TYPE){
rippleStrokeWidth=0;
paint.setStyle(Paint.Style.FILL);
}else
paint.setStyle(Paint.Style.STROKE);
paint.setColor(rippleColor);
rippleParams=new LayoutParams((int)(2*(rippleRadius+rippleStrokeWidth)),(int)(2*(rippleRadius+rippleStrokeWidth)));
rippleParams.addRule(CENTER_IN_PARENT, TRUE);
animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorList=new ArrayList<Animator>();
for(int i=0;i<rippleAmount;i++){
RippleView rippleView=new RippleView(getContext());
addView(rippleView,rippleParams);
rippleViewList.add(rippleView);
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
scaleXAnimator.setStartDelay(i * rippleDelay);
scaleXAnimator.setDuration(rippleDurationTime);
animatorList.add(scaleXAnimator);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
scaleYAnimator.setStartDelay(i * rippleDelay);
scaleYAnimator.setDuration(rippleDurationTime);
animatorList.add(scaleYAnimator);
final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
alphaAnimator.setStartDelay(i * rippleDelay);
alphaAnimator.setDuration(rippleDurationTime);
animatorList.add(alphaAnimator);
}
animatorSet.playTogether(animatorList);
}
示例15: initializeAnimators
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void initializeAnimators(float startRadius, float endRadius, int duration) {
mAnimatorSet = new AnimatorSet();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(mRippleView, "radius", startRadius, endRadius);
scaleXAnimator.setRepeatCount(ValueAnimator.INFINITE);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mRippleView, "alpha", 1f, 0f);
alphaAnimator.setRepeatCount(ValueAnimator.INFINITE);
mAnimatorSet.setDuration(duration);
mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimatorSet.playTogether(scaleXAnimator, alphaAnimator);
}