Custom editText on android

I'm newbie with android layout, so i need some help.

I want create a custom editText, something like this:

An email field with this blue "bar" in the left side

I'm want to fix that with the best possible way.

Someone?

Thanks.

Upvotes: 1

Views: 446

Answers (2)

Zain
Zain

Reputation: 2372

If you want the blue line on the left, you can just set the background on the EditText, such as,

    <EditText
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:background="@drawable/custom_edittext"
        android:layout_weight="1" />

Then create another file in your drawable folder this is called custom_layer.xml

   <?xml version="1.0" encoding="utf-8"?>
   <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="-5dp"
        android:right="-5dp"
        android:top="-5dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/color_of_the_background" />
            <stroke
                android:width="5dp"
                android:color="@color/color_of_the_border" />
        </shape>
    </item>
</layer-list>

And a final selector file - custom_edittext.xm.

<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/custom_layer">        
    </item>
</selector>

Upvotes: 2

Edwin
Edwin

Reputation: 531

U can create a Shape drawable and set shape drawable as the EditText background

Upvotes: 1

Related Questions