The android.widget.AnalogClock and android.widget.DigitalClock classes provides the functionality to display analog and digital clocks.

Android analog and digital clocks are used to show time in android application.

Android AnalogClock is the subclass of View class.

Android DigitalClock is the subclass of TextView class. Since Android API level 17, it is deprecated. You are recommended to use TextClock Instead.

The AnalogClock was deprecated in API level 23. This widget is no longer supported. Instead if you want to use AnalogClock in your application you need to hard code. It does not appear in API level 27 to drag from palette.

Note: Analog and Digital clocks cannot be used to change the time of the device. To do so, you need to use DatePicker and TimePicker.

In android, you need to drag analog and digital clocks from the pallet to display analog and digital clocks.


Now, drag the analog and digital clocks, now the xml file will look like this.

File: activity_main.xml
<?xml version=“1.0” encoding=“utf-8”?>
< xmlns:android=“”
        app:layout_constraintTop_toTopOf=“parent” />
        app:layout_constraintTop_toTopOf=“parent” />

Activity class

We have not write any code here.

import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {


android analog and digital clocks example 1