You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried modifying the code so that a sweeping second hand effect could be achieved, similar to expensive watches like Rolex have. I know that I should animate the second hand, but don't quite know how to implement it.
First I tried setting the delay in: public void setTime(Calendar calendar) { mCalendar = calendar; invalidate(); if (autoUpdate) { new Handler().postDelayed(new Runnable() { @Override public void run() { setTime(Calendar.getInstance()); } }, 1000); } }
to 250 instead of 1000 and modifying the updateHands() slightly so that second hand would update more often. Obviously 250ms was little bit too much and the second hand jumped weirdly.
Hello!
I tried modifying the code so that a sweeping second hand effect could be achieved, similar to expensive watches like Rolex have. I know that I should animate the second hand, but don't quite know how to implement it.
First I tried setting the delay in:
public void setTime(Calendar calendar) { mCalendar = calendar; invalidate(); if (autoUpdate) { new Handler().postDelayed(new Runnable() { @Override public void run() { setTime(Calendar.getInstance()); } }, 1000); } }
to 250 instead of 1000 and modifying the
updateHands()
slightly so that second hand would update more often. Obviously 250ms was little bit too much and the second hand jumped weirdly.I realized that animation is a better idea.
I looked at this example: https://stackoverflow.com/questions/13719890/how-to-make-android-sweeping-second-hand-on-analog-clock
but realized this widget is using
canvas
instead ofImageView
and found out that a good way would be to useMatrix
while animating. Something similar to this:https://stackoverflow.com/questions/27832881/animate-rotation-of-an-image-in-android
Unfortunately I can't quite get it to work.
Any suggestions or pointers?
The text was updated successfully, but these errors were encountered: