Tuesday, 25 February 2014

Different Types of EditText Styles Creation in Android

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Different types of EditText"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:textColor="#336633"
        android:textStyle="bold"
        android:textSize="20sp"/>
   
    <LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
       
       
         <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Plain Text"
        android:ems="7" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="7"
        android:hint="Person Name"
        android:inputType="textPersonName"/>
       
       
    </LinearLayout>
<LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="7"
        android:hint="Text Password"
        android:inputType="textPassword" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="7"
        android:hint="Number Password"
        android:inputType="numberPassword" />
</LinearLayout>


<LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
<EditText
    android:id="@+id/editText5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Text Email Address"
    android:inputType="textEmailAddress" />

<EditText
    android:id="@+id/editText6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Phone"
    android:inputType="phone" />
</LinearLayout>


<LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
<EditText
    android:id="@+id/editText7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
android:hint="Time"   
    android:inputType="time" />

<EditText
    android:id="@+id/editText8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Date"
    android:inputType="date" />
</LinearLayout>

<LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
<EditText
    android:id="@+id/editText9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Number"
    android:inputType="number" />

<EditText
    android:id="@+id/editText10"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Number Signed"
    android:inputType="numberSigned" />
</LinearLayout>

    <LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="5dp">
       
<EditText
    android:id="@+id/editText11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Text Postal Address"
    android:inputType="textPostalAddress" />

<EditText
    android:id="@+id/editText12"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="7"
    android:hint="Number Decimal"
    android:inputType="numberDecimal" />
</LinearLayout>

    <EditText
        android:id="@+id/editText13"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:layout_margin="5dp"
        android:inputType="textMultiLine" />

</LinearLayout>

EditTextStyleActivity.java

package com.anju.tiwari.edittextstyle;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;






public class EditTextStyleActivity extends Activity {

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


}










AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.anju.tiwari.edittextstyle"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name="com.anju.tiwari.edittextstyle.EditTextStyleActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>