Set EditText Gradient Background with Rounded Border Android

Create Gradient like Iphone Edittext box in android.

Building iPhone like editText forms is very easy in android apps, developer can easily make iPhone like data submission forms in android by using another layout xml file and add android EditText inside background with gradient effect. So here is the complete step by step tutorial for Set EditText Gradient Background with Rounded Border Android.

android-project-download-code-button

How to Set EditText Gradient Background with Rounded Border Android.

Code for MainActivity.java file.

package com.edittextlikeiphone_android_examples.com;
import android.app.Activity;
import android.os.Bundle;


public class MainActivity extends Activity {

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

Code for activity_main.xml layout file.

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.edittextlikeiphone_android_examples.com.MainActivity" >

 <EditText
 android:id="@+id/editText1"
 android:layout_width="wrap_content"
 android:layout_height="55dp"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:ems="10"
 android:gravity="center"
 android:background="@layout/iphone_edittext_into_android"
 android:hint="Iphone Like EditText" >

 <requestFocus />
 </EditText>

</RelativeLayout>

Code for iphone_edittext_into_android.xml file.

 <?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <stroke 
 android:color="#028b53"
 android:width="2.5dp" />
 <corners android:radius="10dp" />
 <gradient
 android:type="linear"
 android:angle="270"
 android:startColor="#c3c3c3"
 android:endColor="#FFFFFF" />
</shape>

Screenshot:

Set EditText Gradient Background with Rounded Border Android

Click Here To Download Set EditText Gradient Background with Rounded Border Android project.

Leave a Reply

Your email address will not be published. Required fields are marked *