Home Next Tutorial

How To change theame of edittext in Android


Step 1: Open Android Studio
Step 2: Select File->New->New Project
Step 3: In the Create New Project window type Application Name as "TheameDemo" and click on Next button. In the Target Android Devices select Minimum SDK and click on Next Button. In The Add an Activity to Mobile select blank activity and click on Next Button.Click on Finish button.
Step 4: Design an activity as shown below:

Intent Example
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="User Name:"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#020202" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etName"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Password:"
android:id="@+id/textView2"
android:layout_below="@+id/etName"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#010101" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etPassword"
android:layout_below="@+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/btnLogin"

android:layout_below="@+id/etPassword"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>


Step 5: Now right click on app->res->drawable and select New->Drawable Resource File. specify name of file as myedit and click on OK button. It will create myedit.xml file as shown below:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>

Step 6: Write following code in the myedit.xml file

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#ffffff"/>
<corners
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"/>
</shape>

Step 7:Now set the background property of each edittext to @drawable/myedit and height property to 40dp

Step 8:Run the application.


Download Projects


Download Programs