Skip to content

Analog Clock Library is a customizable Android library that displays time in a traditional analog format. Easily integrate a stylish analog clock into your app with adjustable colors, markers, hand styles, ticking sound effects, and more.

License

Notifications You must be signed in to change notification settings

Jumman04/Analogue-Watch

Repository files navigation

App Icon
API Level 17 and above JitPack Version GitHub Forks GitHub Stars GitHub License

Analog Clock Library

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.


Features

  • 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

Installation

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'
}

Usage in XML Layouts

<com.jummania.AnalogClock 
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Usage in Programmatic

AnalogClock analogClock = new AnalogClock(this);

Customization Attributes

Customize the appearance of the AnalogClock view by using the following XML attributes:

Color Attributes

  • background_color: Background color of the clock face
  • minute_marker_color: Color of minute markers
  • hour_marker_color: Color of hour markers
  • second_hand_color: Color of the second hand
  • minute_hand_color: Color of the minute hand
  • hour_hand_color: Color of the hour hand
  • textColor: Text color for hour indicator text

Dimension Attributes

  • minute_marker_height: Height of minute markers
  • hour_marker_height: Height of hour markers
  • textSize: Text size for hour indicator text

Boolean Attributes

  • minute_marker: Enable/disable display of minute markers
  • hour_marker: Enable/disable display of hour markers
  • enable_sound: Enable/disable ticking sound effects
  • enable_hour_text: Enable/disable display of hour indicator text

Text Attributes

  • fontFamily: Font family for hour indicator text

Example XML usage with attributes:

<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"
/>

Programmatic Customization

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)

Feature Requests

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.

How to Request a Feature

  1. Click on the Issues tab.
  2. Click the green "New Issue" button.
  3. Fill in the requested information and submit the issue.

Thank you for using and contributing to the improvement of our library!

About

Analog Clock Library is a customizable Android library that displays time in a traditional analog format. Easily integrate a stylish analog clock into your app with adjustable colors, markers, hand styles, ticking sound effects, and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages