Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView Border Top in different color

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>
like image 969
tinti Avatar asked Feb 23 '23 06:02

tinti


1 Answers

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>
like image 132
Nibha Jain Avatar answered Mar 07 '23 06:03

Nibha Jain