I have a TextView and i want to put a different color on the top border (let's say white) I try something like this but doesn't work (put white border to all margins - left,right,top,bottom)
<TextView
android:layout_height="50dip"
android:text="@string/total"
android:background="@drawable/border_top_textview"
android:textColor="#FFFFFF"
android:id="@+id/totalCash"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:textSize="26dip"
android:layout_weight="0.3"
android:textStyle="bold"></TextView>
and the border_top_textview.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<stroke android:width="2dp" android:height="2dp" android:color="#FFFFFF" />
<solid android:color="#000000" />
<padding android:top="1dp" android:bottom="1dp" />
</shape></item></layer-list>
Simplest way is to use a 9 patch image as background with desired border.
or
try this, may be it will help you ,it will create a LINE at the TOP ,which will look like a border:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="line">
<stroke android:width="5dp" android:color="#FFFF00" />
<solid android:color="#00000000" />
<padding android:top="25dp" />
</shape>
</item>
</layer-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With