Wednesday, February 17, 2016

Android Hello World Application Example For Beginners

Create “Hello World” application. That will display “Hello World” in the middle of the screen in the
red color with white background.

Click Below Link to download Hello World Application. Although i recommend you to read below steps to understand how to develop Android Application

Download Hello World Android Application

Create Hello World Application follow these basic steps. Below Steps are after the configuration of SDK Manager and eclipse.
STEP 1
Start Eclipse and Choose Workspace where you want to save your project

STEP 2 
Click on the file menu -> Select New -> Choose Android Project
 New Android Project Dialog will displayed and fill the required information and click on the finish button



Here In Above Dialog box Create Activity is the name of class you want to specify for your default Activity which will be loaded first when Hello World Example will be executed.


STEP 3
From the Project explorer click on the HelloWorld  -> res - > layout. it will show the main.xml inside layout folder. double click on the main.xml. By clicking on main.xml it will show something like.

Drag the Text View Control from  left panel to black box. and click on the main.xml tab show bottom left near Graphical Layout. now the main coding or designing part starts.

Main.xml file content for Hello World Example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android_orientation="vertical"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="#999">
 
    <TextView
        android_layout_height="fill_parent"
        android_text="Hello World"
        android_textColor="#900"
        android_id="@+id/textView1"
        android_layout_width="fill_parent"
        android_gravity="center_vertical|center_horizontal">
    </TextView>


</LinearLayout>

STEP 4
When you drag  control to Graphical Layout  in background it will generate the xml code appropriate to those control. In our Example we have dragged TextView Control so here we can see the TextView tag. and LinearLayout tag. LinearLayout is the default layout which hold the View Control as well other Layout if you want to specify for your design.



TextView

We have android:text = "Hello World"  attribute which show the text to screen. here we have specified "Hello World".

android:textColor="#900"  you can specify the Text Color in RGB format RED , GREEN and BLUE.
android:layout_height="fill_parent"  TextView Control Height would be equal to the height of its parent control. in our example parent is LinearLayout. same thing would be applied to android:layout_width

android:gravity="center_vertical|center_horizontal"   you can specify the alignment of the control

LinearLayout

android:background="#999"   We have Specified the Background color of LinearLayout to White Color

STEP 5
Click on the run  to execute our Hello World Application Example.


Download Hello World Android Application

Related Posts by Categories

0 comments:

Post a Comment