Reputation: 131
I have created an analog clock for android. But I want to make it a 24 hour clock. I want to display different things within the clock for different times within a 24 hour time period. For eg, I want to display something during dawn, something during night time etc. So for this reason I want to create a 24 hour clock.
One solution that I can think of is, customize the hour hand and minute hands. So that after one hour the hour hand rotates by only 15degrees instead of 30degrees. And the minute hand should rotate by 3degrees every minute instead of by 6 degrees.
But I dont see anything in the analog clock class to customize the rotations. Any clues would be helpful
Upvotes: 0
Views: 1561
Reputation: 5295
There is not a definite method to get time from Analog Clock Widget.
However you coloud use DateFormat
to get time and on the basis of that time you can rotate your minute and hour hand by the method :-
setRotation(float)
of Analog Clock Widget
Upvotes: 0
Reputation: 6042
You should make this a custom view. I find it surprising that android even provides such a specific component in the base framework. Fortunately though, we can look at source code for it, AnalogClock.java.
Start with that code and modify it as needed. It's actually a pretty good example of how to implement a custom view.
Upvotes: 1