Reputation: 322
I am wondering if anybody can help me with designing an editText like the following:
Note the red vertical line meant to show the obligatory field.
Upvotes: 0
Views: 163
Reputation: 3568
I recreated what you are looking for through the layout and it may not be exactly what you are looking for. I gave it a try because I thought it looked pretty good.
This is how it looks when created
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="#d2d2d2">
<EditText
android:layout_width="match_parent"
android:layout_height="54dp"
android:layout_margin="1dp"
android:paddingLeft="16dp"
android:gravity="center_vertical"
android:background="#fff"
android:textColor="#6d6d6d"/>
<view
android:layout_width="1dp"
android:layout_height="56dp"
android:layout_alignParentRight="true"
android:background="@android:color/holo_red_dark"/>
</RelativeLayout>
Upvotes: 4
Reputation: 277
You can use Selector.
For example:
In res-->drawable folder create another xml file with name "custom_edittext.xml" and paste below code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image_edittext_focused" android:state_focused="true"/>
<item android:drawable="@drawable/image_edittext_normal"/>
</selector>
Finally call custom_edittext.xml as background in your editText
<EditText
...
android:background="@drawable/custom_edittext"
...
/>
Upvotes: 1