Create Analog and Digital clock in Android Programming

In previous post i have explain you about Menu creation in Android and that post also got many likes. Thanks to all now I think its time to move on rather than creating a simple menus and buttons in android. Here in this post i am going to explain you that How to create a analog and digital clock in android. As if you are using Android handheld device then it is in system but let us see how it is programmed.

Some recalls:

  • For this post you should have basic knowledge of Android programming.

Read: Android Programming – Basic

and better to read our two posts that contains some GUI creation and some syntax’s.

 Read:How to Create a Simple Button Control – Android Programming

Read:Create A Menu : Android Programming

Lets begin to create a Clock in Android there is inbuilt function are there, You just have to adjust the layouts, position and background color.

So create a new Project and just simply copy and paste the code.

  • for Analog clock:


  • for Digital clock:


Save the project and run this. The output would be like this.

Digital clock output

Now code explanation, As i said that android SDK offers us the syntax for creating the clock. The syntax is <AnalogClock  attribute 1, attribute 2 …../ > for Analog clock and <DigitalClock  attribute 1, attribute 2 …../ > for digital clock.

android:layout_width=”fill_parent” did the full screen mode for your program. Means it will cover full area of your screen.
android:layout_height=”wrap_content” is a command use to just put your content after the clock area.means not in between the screen of clock.

There were many other attributes too for clock.You can learn it from the Android SDK.

Thank you and happy programming.

About Shahid

Shahid is a Engineering student and addicted to Technology. He is Working For iTechCode(Editor-In-Chief) very passionate about blogging and technology. His area of interest includes programming, tech gadgets, gaming, internet marketing, blogging etc.


  1. Root Android says:

    nice tutorial.. I tried it on my desktop android emulator and it worked. Do you have any tutorial on accessing other resources like GPS, orientation sensors etc.. to make some useful app out of that..

    • First of all thanks for comment and visit and soon i will publish some advanced program of Android.

      Subscribe with us for notification.

  2. Kuldeep Khatri says:

    Good one mate.