Creating custom EditText in android

If you want to create a beautiful application, then you have to change the default layout that android provides the developer. Here is the example of how can you change the default EditText design. 

Create your project in the android studio and create a custom_edittext.xml drawable resource file and put the below code into that file.
 
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
    <shape android:shape="rectangle"
        >
        <solid android:color="@color/colorPrimary"/>
        <corners
            android:radius="50dp"/>
    </shape>
</item>

</selector>

And your EditText contains this line.

android:background="@drawable/custom_edittext"
Full EditText code is below:
<EditText
        android:id="@+id/name"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/custom_edittext"
        android:textColor="@color/white"
        android:textSize="20dp"
        />

This more enough of code will give your application a better look and feel. 

Happy Coding! 
Thanks.

Comments