1

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.

  • This already exists. Check [this](http://android-developers.blogspot.com/2015/05/android-design-support-library.html) and look for MaterialEditText. – Kevin Cronly Jun 19 '15 at 14:34

2 Answers2

2

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>
Zain
  • 2,336
  • 1
  • 16
  • 25
1

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

Edwin
  • 461
  • 1
  • 5
  • 14