Manmohanbadaya / custom-analog-clock-view

A customizable analog clock widget for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Analog Clock View

Based on xxv/24AnalogWidget

This is a super easy to implement and highly customizable analog clock library

##Dependency Add this to your app build.gradle file

dependencies {
    compile 'com.tomerrosenfeld.customanalogclockview:custom-analog-clock-view:1.01'
}

##How to use In your layout:

<com.tomerrosenfeld.customanalogclockview.CustomAnalogClock
        android:id="@+id/analog_clock"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

In your activity:

CustomAnalogClock customAnalogClock = (CustomAnalogClock) findViewById(R.id.analog_clock);
customAnalogClock.setAutoUpdate(true);

####And you're basically done!

Default clock Drawing

#Customization You can completely change the look of the widget by using the init function:

init(Context context, @DrawableRes int watchFace, @DrawableRes int hourHand, @DrawableRes int minuteHand, int alpha, boolean is24, boolean hourOnTop)

So for example:

customAnalogClock.init(MainActivity.this, R.drawable.default_face, R.drawable.default_hour_hand, R.drawable.default_minute_hand, 0, false, false);

In this example, we are creating an analog clock with custom drawables, the background is R.drawable.default_face, the hour hand is R.drawable.default_hour_hand and the minute hand is R.drawable.default_minute_hand.

In addition to that, we chose to keep the clock 12H, like a standard clock, if you want to make it 24H, pass true for is24.

The alpha parameter sets the opacity of the hour hand, set it to 0 to make it completely visible (alpha can vary between 1-254).

The hourOnTop parameter determines the hour hand placement. If set to true, the hour hand will appear on top of the minutes hand, otherwise, the minute hand will show up on top.

I suggest that you base your clock drawables on my default ones:

The Face

The Hour Hand

The Minute Hand

Using this library I was easily able to create these analog clock widgets:

Pebble Theme S7 Theme Default
Pebble Theme S7 Theme Flat style

Licensing

Always On Display is licensed under the GNU v3 Public License.

About

A customizable analog clock widget for Android

License:GNU General Public License v3.0


Languages

Language:Java 100.0%