Thursday, April 12, 2012

Android MOBILE SCREEN SIZES


Android MOBILE SCREEN SIZES



MOBILE SCREEN SIZES

Android screen size is different for different phone models.
There are some screen resolutions already defined in Android.
They are:
§  QVGA (240×320, low density, small screen)
§  WQVGA (240×400, low density, normal screen)
§  FWQVGA (240×432, low density, normal screen)
§  HVGA (320×480, medium density, normal screen)
§  WVGA800 (480×800, high density, normal screen)
§  WVGA854 (480×854 high density, normal screen)

Android - Combining Multiple Layouts in a Layout


Android - Combining Multiple Layouts in a Layout


COMBINING LAYOUTS IN A LAYOUT

The main.xml file is

<?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" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Layout 1" />
<include android:id="@+id/cell1" layout="@layout/layout1" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Layout 2" />
<include android:id="@+id/cell2" layout="@layout/layout2" />
</LinearLayout>

The layout1.xml file is

<?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="wrap_content"
android:background="#ff0000" >
<TextView android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="TextView" />
                <EditText android:layout_width="250px"
android:layout_height="wrap_content"
                                android:hint="EditText" />
                <CheckBox android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="Checkbox" />
</LinearLayout>

The layout2.xml file is

<?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="wrap_content"
android:background="#00ff00" >
<TextView android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="TextView" />
                <EditText android:layout_width="250px"
android:layout_height="wrap_content"
                                android:hint="EditText" />
                <CheckBox android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="Checkbox" />
</LinearLayout>

The OUTPUT will be

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-ZoyDeC-3WOdZlKlBED3sn9EUucBZ50DIuSs7614z0LfIYifCANMaU-nrWYYbOQKUag5V8xs7Rz9Y-W5AuclX7z903kAyTqoYhRFSOILa28xMD-MKl8Hups4ZuBkJWiW53RTylXd6cAI/

Android - Structure of the Manifest.xml File


Android - Structure of the Manifest.xml File



 STRUCTURE OF THE MANIFEST.XML FILE 

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

<manifest>
<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens />
<supports-gl-texture />

<application>
<activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>

<activity-alias>
<intent-filter> . . . </intent-filter>
<meta-data />
</activity-alias>

<service>
<intent-filter> . . . </intent-filter>
<meta-data/>
</service>

<receiver>
<intent-filter> . . . </intent-filter>
<meta-data />
</receiver>

<provider>
<grant-uri-permission />
<meta-data />
</provider>

<uses-library />
</application>

</manifest>

Android Simple Spinner Example


Android Simple Spinner Example



SIMPLE SPINNER

SOURCE CODE [main.xml] is

<?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">
<Spinner android:id="@+id/spin"
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_gravity="center">
</Spinner>
</LinearLayout>

SOURCE CODE [SpinnerExample.java] is

package com.SpinnerExample;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class SpinnerExample extends Activity
{
Spinner sp;
                ArrayAdapter<String> adapter;
                String numbers[] = { "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN",
                                                "EIGHT", "NINE", "TEN" };

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
                                setContentView(R.layout.main);

                                sp = (Spinner) findViewById(R.id.spin);
                                
                                adapter = new ArrayAdapter<String>(this,
                                                                android.R.layout.simple_spinner_item, numbers);
                                sp.setAdapter(adapter);
                }
}

The OUTPUT will be

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjORuUVu7pWvYUfc64aaCqV_Nh_zUbIOcFM7ji0_iwDwM2dYqAYJKFkMeUXh1u0kw8LdbAMJfKJB4xJnUIzyi1zyQyhfyTSSgVyfMTarQ4kCjBw4i9HRqBUtStplIBwuZzTlBFrWaXgIPo/https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvDo0wRg_2hUvRUo0hr5MSMyXS4GmgcpK5MsAoY7rnU1_fkfJ88aEa4Z9FXb-Tt-sjl94-Aa24u43VGmIpzmOMg2APcOsjiLIZrI1LZ5vGjwpyFkocgafH-UPd1xz97a6taCIZsQLEd_A/

Android - Combining Multiple Layouts in a Layout


Android - Combining Multiple Layouts in a Layout



COMBINING LAYOUTS IN A LAYOUT

The main.xml file is

<?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" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Layout 1" />
<include android:id="@+id/cell1" layout="@layout/layout1" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Layout 2" />
<include android:id="@+id/cell2" layout="@layout/layout2" />
</LinearLayout>

The layout1.xml file is

<?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="wrap_content"
android:background="#ff0000" >
<TextView android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="TextView" />
                <EditText android:layout_width="250px"
android:layout_height="wrap_content"
                                android:hint="EditText" />
                <CheckBox android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="Checkbox" />
</LinearLayout>

The layout2.xml file is

<?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="wrap_content"
android:background="#00ff00" >
<TextView android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="TextView" />
                <EditText android:layout_width="250px"
android:layout_height="wrap_content"
                                android:hint="EditText" />
                <CheckBox android:layout_width="fill_parent"
                                android:layout_height="40px"
android:text="Checkbox" />
</LinearLayout>

The OUTPUT will be

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-ZoyDeC-3WOdZlKlBED3sn9EUucBZ50DIuSs7614z0LfIYifCANMaU-nrWYYbOQKUag5V8xs7Rz9Y-W5AuclX7z903kAyTqoYhRFSOILa28xMD-MKl8Hups4ZuBkJWiW53RTylXd6cAI/