Analog Clock Library is a customizable Android library for displaying time in a traditional analog format. It provides developers with a range of customization options to adjust various aspects such as hour markers, minute markers, hour indicator text, and clock hands (hour, minute, second) to suit their application's design.
- Display time in a traditional analog format
- Customize background color, marker colors, and hand colors
- Adjust heights and widths of minute markers, hour markers, and hands
- Enable/disable minute markers, hour markers, and hour indicator text
- Ticking sound effects with adjustable volume
- Customize text size, font family, text color, and text style for hour indicator text
Add JitPack repository to your root build.gradle file: Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
// Other repositories...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.Jumman04:Analogue-Watch:4.2'
}
<com.jummania.AnalogClock
android:layout_width="match_parent"
android:layout_height="match_parent" />
AnalogClock analogClock = new AnalogClock(this);
Customize the appearance of the AnalogClock
view by using the following XML attributes:
background_color
: Background color of the clock faceminute_marker_color
: Color of minute markershour_marker_color
: Color of hour markerssecond_hand_color
: Color of the second handminute_hand_color
: Color of the minute handhour_hand_color
: Color of the hour handtextColor
: Text color for hour indicator text
minute_marker_height
: Height of minute markershour_marker_height
: Height of hour markerstextSize
: Text size for hour indicator text
minute_marker
: Enable/disable display of minute markershour_marker
: Enable/disable display of hour markersenable_sound
: Enable/disable ticking sound effectsenable_hour_text
: Enable/disable display of hour indicator text
fontFamily
: Font family for hour indicator text
<com.jummania.AnalogClock
android:layout_width="match_parent"
android:layout_height="match_parent"
app:background_color="@color/white"
app:minute_marker_color="@color/gray"
app:hour_marker_color="@color/black"
app:textColor="@color/black"
app:second_hand_color="@color/red"
app:minute_hand_color="@color/blue"
app:hour_hand_color="@color/green"
app:minute_marker_height="0.1"
app:hour_marker_height="0.15"
app:second_hand_height="0.9"
app:minute_hand_height="0.8"
app:hour_hand_height="0.7"
app:second_hand_width="0.02"
app:minute_hand_width="0.03"
app:hour_hand_width="0.04"
app:minute_marker="true"
app:hour_marker="true"
app:enable_hour_text="true"
app:enable_second_hand="true"
app:enable_minute_hand="true"
app:enable_hour_hand="true"
app:enable_sound="true"
app:volume="0.5"
app:clock_sound="@raw/ticking_sound"
app:textSize="14sp"
app:fontFamily="sans-serif"
app:textStyle="normal"
/>
You can also customize the AnalogClock view programmatically:
analogClock.setBackgroundColor(Color.WHITE)
analogClock.setMarkerColor(minuteMarkerColor = Color.GRAY, hourMarkerColor = Color.BLACK)
analogClock.setHandColor(secondHandColor = Color.RED, minuteHandColor = Color.BLUE, hourHandColor = Color.GREEN)
analogClock.setTextColor(Color.BLACK)
analogClock.setMarkerHeight(minuteMarkerHeight = 0.1f, hourMarkerHeight = 0.15f)
analogClock.setHandHeight(secondHandHeight = 0.8f, minuteHandHeight = 0.7f, hourHandHeight = 0.6f)
analogClock.setHandWidth(secondHandWidth = 0.02f, minuteHandWidth = 0.03f, hourHandWidth = 0.04f)
analogClock.setTextSize(14f)
analogClock.enableHourText(true)
analogClock.enableSound(true)
analogClock.enableMarkers(minuteMarker = true, hourMarker = true)
analogClock.enableHands(secondHand = true, minuteHand = true, hourHand = true)
analogClock.setVolume(0.5f)
analogClock.setMediaPlayer(R.raw.clock_tick)
analogClock.setTypeface(Typeface.SANS_SERIF)
If you have a feature request or a suggestion for improving this library, please feel free to open an issue and let us know! We appreciate your feedback and are always looking to make our library better.
- Click on the Issues tab.
- Click the green "New Issue" button.
- Fill in the requested information and submit the issue.