Analog Clock And Digital Clock
Designing Part:
Adding color :
In this Example we want to add color for BG in Values/string.xml as bellow:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, TimePickerDialodActivity!</string>
<string name="app_name">TimePickerDialod</string>
<color name="MediumPurple4">#4E387E</color>
</resources>
Layout file: Main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_height="wrap_content"
android:id="@+id/analog"
android:layout_width="fill_parent"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:background="@color/MediumPurple4">
</AnalogClock>
<DigitalClock android:layout_height="wrap_content"
android:id="@+id/digital"
android:layout_width="wrap_content"
android:layout_below="@+id/analog"
android:layout_marginTop="23dp"
android:background="@color/MediumPurple4"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:textStyle="bold"
android:textSize="40dip">
</DigitalClock>
</RelativeLayout>
Coding Part:
Here there is no code modifications.
package com.murali.AnalogAndDigital;
import android.app.Activity;
import android.os.Bundle;
public class TimePickerDialodActivity extends Activity {
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
}
Explanation for javaCode:
The following Properties Add to Analog clock ad Digital Clock:
android:background="@color/MediumPurple4"
-- > this is Resource for background color.
-- > this is Resource for background color.
android:textStyle="bold" ----> This line Change the Style of Text as BOLD.
android:textSize="40dip" --- >This change Size Of the Text.
Thanks for the example man!! Even this http://www.compiletimeerror.com/2013/08/analog-and-digital-clock-in-android.html might help you, have a look..
ReplyDeleteThanks for your post!
ReplyDeleteDigital clock online