I want to make a custom clock(with hand) page.
The goal is that:when I long press the red button,the hand should rotate with the crossing dot;when I off the button ,the hand stop at the last position,so i use the listener to tell the handler ,update datas.
but now, the hand rotated with dot which is the middle dot of hand,That's not my result.
I use code like next:
ObjectAnimator animator = ObjectAnimator.ofFloat(hand, "rotation", 0F, 360F);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(6000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@override
public void onAnimationUpdate(ValueAnimator animation) {
float angel = (float) animation.getAnimatedValue("rotation");
Message message = Message.obtain();
Bundle bundle = new Bundle();
bundle.putFloat("value", angel);
message.setData(bundle);
handler.sendMessage(message);
}
});
My Question is :" How i modify the code to realize my goal"?
This is my first question in here,please help me ,Thanks very much !
The goal is that:when I long press the red button,the hand should rotate with the crossing dot;when I off the button ,the hand stop at the last position,so i use the listener to tell the handler ,update datas.
but now, the hand rotated with dot which is the middle dot of hand,That's not my result.
I use code like next:
ObjectAnimator animator = ObjectAnimator.ofFloat(hand, "rotation", 0F, 360F);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(6000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@override
public void onAnimationUpdate(ValueAnimator animation) {
float angel = (float) animation.getAnimatedValue("rotation");
Message message = Message.obtain();
Bundle bundle = new Bundle();
bundle.putFloat("value", angel);
message.setData(bundle);
handler.sendMessage(message);
}
});
My Question is :" How i modify the code to realize my goal"?
This is my first question in here,please help me ,Thanks very much !