What is analog and digital clock

Android analog and digital clock is used to display the curret time from current device.


Analog and Digital clock:.

In this section i am going to show the analog and digital clock with practical example.

First open the android studio and create a project and give the name of your project like AnalogDigitalClockDemo.

The screenshots of the program is as follows:

Smiley face Smiley face

Drag and drop the analog and digital clock from the pallet. Open the activity_main.xml file and code look like this


<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="22dp" />

    <DigitalClock
        android:id="@+id/digitalClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/analogClock1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="81dp"
        android:text="DigitalClock" />

</android.support.constraint.ConstraintLayout>
       

Open the MainActivity.java file and code look like this. You do not have write any code here.


package com.example.niitpc.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}


       

Explanation:

you do not have to write any code only drag and drop analog and digital clock and run it.:


Analog and digital clock

What is analog and digital clock for video Click here

Smiley face                     Smiley face