This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AnimatorSet animatorSet = new AnimatorSet(); | |
List<Animator> animatorList = ... //collection of ValueAnimator | |
animatorSet.playSequentially(animatorList); | |
animatorSet.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//values are hardcoded for demo only | |
private ValueAnimator createAnimator() { | |
PropertyValuesHolder propertyX = PropertyValuesHolder.ofInt(PROPERTY_X, 100, 300); | |
PropertyValuesHolder propertyY = PropertyValuesHolder.ofInt(PROPERTY_Y, 100, 300); | |
PropertyValuesHolder propertyAlpha = PropertyValuesHolder.ofInt(PROPERTY_ALPHA, 0, 255); | |
ValueAnimator animator = new ValueAnimator(); | |
animator.setValues(propertyX, propertyY, propertyAlpha); | |
animator.setDuration(2000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PropertyValuesHolder propertyRadius = PropertyValuesHolder.ofInt(PROPERTY_RADIUS, 0, 150); | |
PropertyValuesHolder propertyRotate = PropertyValuesHolder.ofInt(PROPERTY_ROTATE, 0, 360); | |
animator = new ValueAnimator(); | |
animator.setValues(propertyRadius, propertyRotate); | |
animator.setDuration(2000); | |
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator animation) { | |
radius = (int) animation.getAnimatedValue(PROPERTY_RADIUS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int radius; // at the beggining radius equals 0 | |
@Override | |
protected void onDraw(Canvas canvas) { | |
int viewWidth = getWidth() / 2; | |
int viewHeight = getHeight() / 2; | |
int leftTopX = viewWidth - 150; | |
int leftTopY = viewHeight - 150; | |
int rightBotX = viewWidth + 150; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ValueAnimator animator = ValueAnimator.ofInt(0, 100); | |
animator.setDuration(2000); | |
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator animation) { | |
int value = (int) animation.getAnimatedValue(); | |
} | |
}); | |
animator.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ValueAnimator animator = ValueAnimator.ofInt(0, 100); | |
animator.setDuration(1000); | |
animator.setInterpolator(new DecelerateInterpolator()); | |
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
public void onAnimationUpdate(ValueAnimator animation) { | |
int newRadius = (int) animation.getAnimatedValue(); | |
} | |
}); | |
animator.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int width; | |
if (widthMode == MeasureSpec.EXACTLY) { | |
width = widthSize; | |
} else if (widthMode == MeasureSpec.AT_MOST) { | |
width = Math.min(desiredWidth, widthSize); | |
} else { | |
width = desiredWidth; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
int widthMode = MeasureSpec.getMode(widthMeasureSpec); | |
int widthSize = MeasureSpec.getSize(widthMeasureSpec); | |
int heightMode = MeasureSpec.getMode(heightMeasureSpec); | |
int heightSize = MeasureSpec.getSize(heightMeasureSpec); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public PageIndicatorView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PageIndicatorView); | |
int count = typedArray.getInt(R.styleable.PageIndicatorView_piv_count,0); | |
typedArray.recycle(); | |
} |