Thursday 19 April 2012

Rounded corner Edittext in android

Here below example shows how to set Rounded corners to EditText

Create (round.xml) file in drawable folder of your project 

Copy below code:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >
    <solid android:color="#FFFFFFFF" />
    <corners android:radius="20dp" />
</shape>

Use this layout as background
to EditText


<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:background="@android:color/darker_gray"
    tools:context=".RoundedCornerEditText" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/round"
        android:ems="10"
        android:padding="5dp"
        android:text="Hi am rounded corner EditText Box"
        android:textSize="15dp" />

</RelativeLayout>

Output ScreenShot:


No comments:

Post a Comment

Android SQLite Database Viewer or Debuging with Stetho

Every Android Developer uses SQLite Database to store data into the Android Application data. But to view the data in SQLite have a lot of...