本文整理汇总了Java中android.view.animation.CycleInterpolator类的典型用法代码示例。如果您正苦于以下问题:Java CycleInterpolator类的具体用法?Java CycleInterpolator怎么用?Java CycleInterpolator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CycleInterpolator类属于android.view.animation包,在下文中一共展示了CycleInterpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SquareKey
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* Public constructor.
*
* @param pinView {@link PinView}
* @param digit title of the key. (-1 for the backspace key)
* @param bounds {@link Rect} bound.
*/
private SquareKey(@NonNull PinView pinView,
@NonNull String digit,
@NonNull Rect bounds,
@NonNull SquareKey.Builder builder) {
super(pinView, digit, bounds, builder);
mBounds = bounds;
mBuilder = builder;
//Error animator
mErrorAnimator = ValueAnimator.ofInt(0, 10);
mErrorAnimator.setInterpolator(new CycleInterpolator(2));
mErrorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBounds.left += (int) animation.getAnimatedValue();
mBounds.right += (int) animation.getAnimatedValue();
getPinView().invalidate();
}
});
}
示例2: RectKey
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* Public constructor.
*
* @param pinView {@link PinView}
* @param digit title of the key. (-1 for the backspace key)
* @param bounds {@link Rect} bound.
*/
private RectKey(@NonNull PinView pinView,
@NonNull String digit,
@NonNull Rect bounds,
@NonNull RectKey.Builder builder) {
super(pinView, digit, bounds, builder);
mBounds = bounds;
mBuilder = builder;
//Error animator
mErrorAnimator = ValueAnimator.ofInt(0, 10);
mErrorAnimator.setInterpolator(new CycleInterpolator(2));
mErrorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBounds.left += (int) animation.getAnimatedValue();
mBounds.right += (int) animation.getAnimatedValue();
getPinView().invalidate();
}
});
}
示例3: initInterpolations
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
private void initInterpolations() {
ArrayList<Class> interpolatorList = new ArrayList<Class>() {{
add(FastOutSlowInInterpolator.class);
add(BounceInterpolator.class);
add(LinearInterpolator.class);
add(DecelerateInterpolator.class);
add(CycleInterpolator.class);
add(AnticipateInterpolator.class);
add(AccelerateDecelerateInterpolator.class);
add(AccelerateInterpolator.class);
add(AnticipateOvershootInterpolator.class);
add(FastOutLinearInInterpolator.class);
add(LinearOutSlowInInterpolator.class);
add(OvershootInterpolator.class);
}};
try {
interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: onAction
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
@OnClick(R.id.btn_start)
public void onAction() {
// float start = mView.getY();
// if (start > 680f) {
// start = 0f;
// mView.setY(0f);
// }
// Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
// Keyframe kf1 = Keyframe.ofFloat(.5f, 360f);
// Keyframe kf2 = Keyframe.ofFloat(1f, 0f);
// PropertyValuesHolder pvh = PropertyValuesHolder.ofKeyframe("X", kf0, kf1, kf2);
// ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(mView, pvh);
//
// anim.setDuration(5000);
// anim.setInterpolator(new AccelerateDecelerateInterpolator());
// anim.start();
ObjectAnimator animX = ObjectAnimator.ofFloat(mView, "x", 0, 50f);
ObjectAnimator animY = ObjectAnimator.ofFloat(mView, "y", 0, 100f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.setInterpolator(new CycleInterpolator(0.5f));
animSetXY.start();
}
示例5: initAnimation
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
private void initAnimation(){
pushLeftIn = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 1.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
pushLeftIn.setDuration(200);
pushLeftIn.setFillAfter(true);
pushLeftOut = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, -1.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
pushLeftOut.setDuration(200);
pushLeftOut.setFillAfter(true);
shakeAni = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.05f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
shakeAni.setDuration(300);
shakeAni.setInterpolator(new CycleInterpolator(2.0f));
}
示例6: run
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
@Override
public void run() {
if (mView != null && mView.getWidth() != 0 && mView.getHeight() != 0) {
if (bounceViewAnimation != null && !bounceViewAnimation.hasEnded()) {
return;
}
bounceViewAnimation = new ScaleAnimation(1f, mRatio, 1f, mRatio, mView.getWidth() / 2, mView.getHeight() / 2);
// Define the parameters of the animation
bounceViewAnimation.setDuration(mTime);
bounceViewAnimation.setInterpolator(new CycleInterpolator(0.5f));
mView.setVisibility(View.VISIBLE);
mView.startAnimation(bounceViewAnimation);
}
if (mInfiniteBounce) {
bounceViewHandler.postDelayed(bounceViewRunnable, 2000);
}
}
示例7: shakeView
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* To shake a view
* @param view
*/
protected void shakeView(View view){
float delta = 10.0f;
CycleInterpolator cycle = new CycleInterpolator(6);
AnimationSet animSet = new AnimationSet(false);
Animation anim = new TranslateAnimation(0, delta, 0, 0);
anim.setDuration(500);
anim.setInterpolator(cycle);
animSet.addAnimation(anim);
view.startAnimation(animSet);
try{
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(300);
}catch(Exception e){}
}
示例8: shake
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
public static void shake(View view, Option option) {
if (option == null) {
option = getOption(view.getContext());
}
TranslateAnimation ta = new TranslateAnimation(-option.mOffsetX,
option.mOffsetX, -option.mOffsetY, option.mOffsetY);
ta.setDuration(option.mDuration);
ta.setInterpolator(new CycleInterpolator(option.mRepeatCount));
view.startAnimation(ta);
if (option.mVibrate) {
Vibrator v = (Vibrator) view.getContext().getSystemService(
Context.VIBRATOR_SERVICE);
v.vibrate(getVibratePattern(option), -1);
}
}
示例9: preparePulseAnimation
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* This animation will make a pulse effect to the inner circle
*
* @return Animation
*/
private Animator preparePulseAnimation() {
AnimatorSet animation = new AnimatorSet();
Animator firstBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.88f);
firstBounce.setDuration(300);
firstBounce.setInterpolator(new CycleInterpolator(1));
Animator secondBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
0.75f, 0.83f);
secondBounce.setDuration(300);
secondBounce.setInterpolator(new CycleInterpolator(1));
Animator thirdBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
0.75f, 0.80f);
thirdBounce.setDuration(300);
thirdBounce.setInterpolator(new CycleInterpolator(1));
animation.playSequentially(firstBounce, secondBounce, thirdBounce);
return animation;
}
示例10: setHinted
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
void setHinted(boolean hinted) {
if (mHinted != hinted) {
mHinted = hinted;
regenerateCachedDrawable();
if (hinted) {
// Throb animation
Animation throbAnimation =
new ScaleAnimation(1.0f, 1.15f, 1.0f, 1.15f, mBounds.centerX(), mBounds.centerY());
throbAnimation.setInterpolator(new CycleInterpolator(0.5f));
throbAnimation.setDuration(HINT_ANIMATION_DURATION_MS);
throbAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
throbAnimation.setAnimationListener(new BaseAnimationListener());
updateAnimation(throbAnimation);
}
}
}
示例11: onIncorrectTriple
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
void onIncorrectTriple() {
mSelected = false;
mShakeAnimating = true;
// Shake animation
Animation shakeAnimation = new RotateAnimation(0, 5, mBounds.centerX(), mBounds.centerY());
shakeAnimation.setInterpolator(new CycleInterpolator(4));
shakeAnimation.setDuration(INCORRECT_ANIMATION_DURATION_MS);
shakeAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
shakeAnimation.setAnimationListener(
new BaseAnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
super.onAnimationEnd(animation);
mShakeAnimating = false;
regenerateCachedDrawable();
}
});
updateAnimation(shakeAnimation);
}
示例12: getShakeAnimation
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* @param shouldResetTextColor if true make sure you end the previous animation before starting this one.
*/
public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) {
final int textColor = textView.getCurrentTextColor();
textView.setTextColor(Color.RED);
ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16);
shakeAnim.setDuration(SHAKE_DURATION);
shakeAnim.setInterpolator(new CycleInterpolator(2.0f));
shakeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
if (shouldResetTextColor) {
textView.setTextColor(textColor);
}
}
});
return shakeAnim;
}
示例13: initShowAnimation
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
@Override
protected Animation initShowAnimation() {
AnimationSet set=new AnimationSet(false);
Animation shakeAnima=new RotateAnimation(0,15,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
shakeAnima.setInterpolator(new CycleInterpolator(5));
shakeAnima.setDuration(400);
set.addAnimation(getDefaultAlphaAnimation());
set.addAnimation(shakeAnima);
return set;
}
示例14: parse
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
public static Interpolator parse(Integer type, Float cycles) {
if (type != null) {
switch (type) {
case 0:
return new AccelerateDecelerateInterpolator();
case 1:
return new AccelerateInterpolator();
case 2:
return new AnticipateInterpolator();
case 3:
return new AnticipateOvershootInterpolator();
case 4:
return new BounceInterpolator();
case 5:
return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f);
case 6:
return new DecelerateInterpolator();
case 7:
return new LinearInterpolator();
case 8:
return new OvershootInterpolator();
//暂时不支持的
// case 7: return new FastOutLinearInterplator();
// case 8: return new FastOutSlowInInterplator();
// case 10: return new LinearOutSlowInInterplator();
// case 12: return new PathInterplator();
default:
return new LinearInterpolator();
}
} else {
return new LinearInterpolator();
}
}
示例15: shakeAnimation
import android.view.animation.CycleInterpolator; //导入依赖的package包/类
/**
* 晃动动画
*
* @param counts 1秒钟晃动多少下
* @return
*/
public static Animation shakeAnimation(int counts) {
Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
translateAnimation.setInterpolator(new CycleInterpolator(counts));
translateAnimation.setDuration(1000);
return translateAnimation;
}