david.ning
david.ning

Reputation: 23

How can I set the style of 'EditText' like this?

How can I set the style of an EditText like this picture in Android?

enter image description here

Upvotes: 2

Views: 715

Answers (2)

jennifer
jennifer

Reputation: 8261

<EditText android:id="@+id/searchTxt" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:hint="Email Address"
        android:textSize="17sp" android:maxLength="10" android:inputType="textFilter"
         android:background="@drawable/textborder"
        android:textStyle="bold" android:paddingLeft="10dp"
        android:layout_marginTop="3dp" android:layout_marginLeft="3dp"
        android:layout_marginBottom="2dp" android:layout_marginRight="2dp"
        android:clickable="true" android:textColor="@color/textcolor"
        android:imeOptions="actionDone">

textborder.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="7px" android:topLeftRadius="7px"
        android:topRightRadius="7px" android:bottomLeftRadius="7px"
        android:bottomRightRadius="7px" />
        <solid android:color="@android:color/transparent" />
    <stroke android:width="0dp" android:color="#000000" />
    <padding android:left="1dp" android:top="1dp" android:right="1dp"
        android:bottom="1dp" />

</shape> 

Upvotes: 0

brianestey
brianestey

Reputation: 8302

I think you need to make a 9 patch (Android docs) and then set that as the background of the edit text.

Upvotes: 1

Related Questions