Saturday, 22 August 2015

Android example for custom grouped Edittext


  Here I am going to explain example for custom grouped edittext for android like an iphone


                            

     

Step 1).group.xml
    
 <?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="#E6E6E6" />

    <padding
        android:bottom="2dp"
        android:left="2dp"
        android:right="2dp"
        android:top="2dp" />

</shape>


Step 2).activity.xml


<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#7faaff" >

<RelativeLayout 
  android:layout_width="match_parent"
  android:layout_height="124dp"
  android:layout_centerInParent="true"
  android:layout_margin="20dp"
  android:layout_marginTop="30dp"
  android:background="@drawable/group" >

<EditText
  android:id="@+id/editText1"
  android:layout_width="wrap_content"
  android:layout_height="40dp"
  android:layout_alignParentLeft="true"
  android:layout_alignParentRight="true"
  android:background="@null"
  android:ems="10"
  android:hint="Name"
  android:imeOptions="actionNext"
  android:padding="10dp"
  android:singleLine="true" >
</EditText>

<View
  android:id="@+id/view1"
  android:layout_width="fill_parent"
  android:layout_height="1dp"
  android:layout_below="@+id/editText1"
  android:background="#c0c0c0" />

<EditText
  android:id="@+id/editText2"
  android:layout_width="match_parent"
  android:layout_height="40dp"
  android:layout_below="@+id/view1"
  android:background="@null"
  android:ems="10"
  android:hint="State"
  android:imeOptions="actionNext"
  android:padding="10dp"
  android:singleLine="true" >
</EditText>

<View
  android:id="@+id/view2"
  android:layout_width="fill_parent"
  android:layout_height="1dp"
  android:layout_below="@+id/editText2"
  android:background="#c0c0c0" />

<EditText
  android:id="@+id/editText3"
  android:layout_width="match_parent"
  android:layout_height="40dp"
  android:layout_alignRight="@+id/view2"
  android:layout_below="@+id/view2"
  android:background="@null"
  android:ems="10"
  android:hint="Country"
  android:imeOptions="actionDone"
  android:padding="10dp"
  android:singleLine="true" >
</EditText>
</RelativeLayout >


</RelativeLayout >

Happy Coding:)