All Projects → leondzn → simple-analog-clock

leondzn / simple-analog-clock

Licence: Apache-2.0 license
Simple clock view for displaying uh...time?

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to simple-analog-clock

React Clock
An analog clock for your React app.
Stars: ✭ 149 (+520.83%)
Mutual labels:  time, clock
time
The simplest but configurable online clock
Stars: ✭ 77 (+220.83%)
Mutual labels:  time, clock
ardusamber
Desamber time Arduino corporealization
Stars: ✭ 20 (-16.67%)
Mutual labels:  time, clock
Use Timer
A timer hook for React
Stars: ✭ 113 (+370.83%)
Mutual labels:  time, clock
timestampy
🕒 Bunch of utilities useful when working with UNIX timestamps
Stars: ✭ 21 (-12.5%)
Mutual labels:  time, clock
React Timer Hook
React timer hook
Stars: ✭ 118 (+391.67%)
Mutual labels:  time, clock
kde-plasmoid-betterinlineclock
Your usual clock widget, just way better and on a single line!
Stars: ✭ 18 (-25%)
Mutual labels:  widget, clock
Klock
Multiplatform Date and time library for Kotlin
Stars: ✭ 569 (+2270.83%)
Mutual labels:  time, clock
telltime
iOS application to tell the time in the British way 🇬🇧⏰
Stars: ✭ 49 (+104.17%)
Mutual labels:  time, clock
TimeContinuum
No description or website provided.
Stars: ✭ 28 (+16.67%)
Mutual labels:  time, clock
Xfce4 Genmon Scripts
🐭 XFCE panel generic monitor scripts
Stars: ✭ 69 (+187.5%)
Mutual labels:  time, widget
ElevenClock
ElevenClock: Customize Windows 11 taskbar clock
Stars: ✭ 1,494 (+6125%)
Mutual labels:  time, clock
Vue Clock2
vue clock component 😀
Stars: ✭ 67 (+179.17%)
Mutual labels:  time, clock
Tzupdate
Set the system timezone based on IP geolocation
Stars: ✭ 130 (+441.67%)
Mutual labels:  time, clock
Truetime Android
Android NTP time library. Get the true current time impervious to device clock time changes
Stars: ✭ 1,134 (+4625%)
Mutual labels:  time, clock
AndroidUiKit
uikit widget common baseview Adapter faster develop
Stars: ✭ 48 (+100%)
Mutual labels:  widget, view
Timestamp
⏰ A better macOS menu bar clock.
Stars: ✭ 296 (+1133.33%)
Mutual labels:  time, clock
Portable Snippets
Collection of miscellaneous portable C snippets.
Stars: ✭ 397 (+1554.17%)
Mutual labels:  time, clock
clocklet
An opinionated clock-style vanilla-js timepicker.
Stars: ✭ 31 (+29.17%)
Mutual labels:  time, clock
vue-analog-clock-range
Vue Analog Clock Range Component
Stars: ✭ 53 (+120.83%)
Mutual labels:  time, clock

simple-analog-clock

Release API Android Arsenal

A simple clock view. The clock drawables can be changed with your own custom assets.

Preview

Prerequisites

Your project must be using AndroidX artifacts instead of Support Libraries. Otherwise your project build will fail due to Manifest merger failed error.

Installation

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.leondzn:simple-analog-clock:${version}'
}

Usage

XML

<com.leondzn.simpleanalogclock.SimpleAnalogClock
    android:id="@+id/clock"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="16dp"
    app:hourTint="@color/colorPrimary"                                        
    app:secondTint="@color/colorAccent" />

The following XML attributes are supported:

app:faceTint, app:hourTint, app:minuteTint, app:secondTint

to colorize the clock's face and hands.

You can manually set the individual hands' rotation value given a specific angle using

app:hourRotation, app:minuteRotation, app:secondRotation

You can also provide custom drawables for the clock using

app:faceDrawable, app:hourDrawable, app:minuteDrawable, app:secondDrawable

More info on providing custom drawables are detailed below.

Java

SimpleAnalogClock clock = findViewById(...);

clock.setSecondTint(...)
  .setTime(hour, minute, second);

You can rotate the clock hands individually using the following methods:

rotateHourHand(angle), rotateMinuteHand(angle), rotateSecondHand(angle)

Using the methods above requires you to calculate the corresponding angles for each time value.

To use exact time values, use the following methods:

setTime(int hour, int minute, int second) or setTime(int hour, int munute, int second, int millis)

Using the millisecond parameter allows for the second hand to turn more smoothly as opposed to traditional analog clock "ticking" behavior.

Similar to the XML attributes, you can also provide custom drawables to use with the analog clock:

setFaceDrawable(Drawable), setHourDrawable(Drawable), setMinuteDrawable(Drawable), setSecondDrawable(Drawable)

Using Custom Drawables

Simple default clock face and hands are provided but you are free to use custom drawables provided that they follow these guidelines:

  • All 4 layers (face, hour hand, minute hand, second hand) should all be the same image size
  • The images should be square
  • Clock hands should be pointing at the 12 o' clock position
  • SVG or PNG can be used

Example:

Face Drawable

Face

Hour Drawable

Short hand

Minute Drawable

Long hand

Second Drawable

Second hand

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].