Skip to content Skip to sidebar Skip to footer

Custom Edittext On Android

I'm newbie with android layout, so i need some help. I want create a custom editText, something like this: I'm want to fix that with the best possible way. Someone? Thanks.

Solution 1:

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

<EditTextandroid: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-listxmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:bottom="-5dp"android:right="-5dp"android:top="-5dp"><shapeandroid:shape="rectangle" ><solidandroid:color="@color/color_of_the_background" /><strokeandroid:width="5dp"android:color="@color/color_of_the_border" /></shape></item></layer-list>

And a final selector file - custom_edittext.xm.

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

Solution 2:

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

Post a Comment for "Custom Edittext On Android"