AnalogClock and DigitalClock views in Android

The AnalogClock view displays an analog clock with two hands — one for minutes and one for hours. Its counterpart, the DigitalClock view, displays the time digitally. Both display the system time, and do not allow you to display a particular time. Hence, if you want to display the time for a particular region, you have to build your own custom   views.

Using the AnalogClock and DigitalClock views are straightforward; simply declare them in your XML file (such as main.xml), like  this:

<?xml version=”1.0” encoding=”utf-8”?>

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical”

android:layout_width=”fill_parent” android:layout_height=”fill_parent”

> 

<AnalogClock

android:layout_width=”wrap_content” android:layout_height=”wrap_content”  />

 

<DigitalClock

android:layout_width=”wrap_content” android:layout_height=”wrap_content”  />

 

</LinearLayout>

Leave a Reply

Your email address will not be published. Required fields are marked *