Specifying the Keyboard Layout of EditText



Hai friends, Today i am going to show you a specific keyboard layout for 'EditText'. If user click on EditText the android system will show a keyboard with general characters.But we can categorize based on the content of the Text field that's will improve the user experience of our application, for example if you want to type phone number in the text field the keyboard layout should only contain of numbers and that will improve user experience of the application.

This is how our android application looks like;


Project Structure;



activity_main.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example..specifyingthekeyboardlayoutofedittext.MainActivity">


    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="33dp"
        android:layout_marginStart="33dp"
        android:layout_marginTop="35dp"
        android:ems="10"
        android:inputType="textEmailAddress"
        android:hint="email address"/>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/editText"
        android:layout_alignRight="@+id/editText"
        android:layout_below="@+id/editText"
        android:layout_marginTop="17dp"
        android:ems="10"
        android:inputType="textUri"
        android:hint="url"/>

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText2"
        android:layout_alignStart="@+id/editText2"
        android:layout_below="@+id/editText2"
        android:layout_marginTop="21dp"
        android:ems="10"
        android:inputType="number"
        android:hint="phone number"/>
</RelativeLayout>


You can download app from here;


You can download full source code of this tutorial here;

Thanks for your comment