Reputation: 943
I saw many related discussions but didn't find a suitable solution. What I need to do is to create a black border on the bottom side of an EditText widget. Is that possible?
Upvotes: 15
Views: 44855
Reputation: 325
Create a layer list with item as below
<item android:bottom="-1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="2dp"
android:color="#111111" />
</shape>
</item>
Upvotes: 3
Reputation: 927
<?xml version="1.0" encoding="utf-8" `enter code here`?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:left="2dp" android:right="-2dp"
android:top="-2dp" android:bottom="2dp" >
<shape android:shape="rectangle">
<stroke android:color="@android:color/black" android:width="2dp">
</stroke>
</shape>
</item>
</layer-list>
Upvotes: 0
Reputation: 11194
I compiled this at my end :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><layer-list>
<item android:bottom="-10dp" android:left="-10dp" android:right="-10dp"><shape>
<gradient android:angle="270" android:endColor="#a0e0b071" android:startColor="#a0a67637" />
<stroke android:width="10dp" android:color="#5c3708" />
<corners android:radius="5dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
</shape></item>
</layer-list></item>
<item android:state_enabled="true"><layer-list>
<item android:bottom="-10dp" android:left="-10dp" android:right="-10dp"><shape android:shape="rectangle">
<gradient android:angle="270" android:endColor="#a0a67637" android:startColor="#a0e0b071" />
<stroke android:width="10dp" android:color="#5c3708" />
<corners android:radius="5dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
</shape></item>
</layer-list></item>
</selector>
Upvotes: 11
Reputation: 5707
just add underlinebg.xml in res/drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="-1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="2dp"
android:color="@color/drawe_content_color_click" />
</shape>
</item>
</layer-list>
and set the background where ever required. For me i got the solution like [![myoutput!!][1]][1] .I think my answer will helpful for others.
Upvotes: 6
Reputation: 5024
simple create one edittext_bottom_line.xml file in drawable folder in res
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="@android:color/black" />
</shape>
</item>
</layer-list>
To set control's single property like these:
<EditText
android:id="@+id/editTextEnterPassword"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@drawable/edittext_bottom_line"
/>
Upvotes: 68
Reputation: 11948
you can create one xml file like follow:
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/orange" />
</shape>
</item>
<item android:bottom="4dp">
<shape android:shape="rectangle" >
<size android:height="4dp" />
<solid android:color="@color/green3" />
</shape>
</item>
then set this file as your background
Upvotes: 2