Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweeping second hand animation #5

Open
ehausen opened this issue Apr 29, 2018 · 0 comments
Open

Sweeping second hand animation #5

ehausen opened this issue Apr 29, 2018 · 0 comments

Comments

@ehausen
Copy link

ehausen commented Apr 29, 2018

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 of ImageView and found out that a good way would be to use Matrix 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant