1

I want to add a bottom border to my textView , something like this :

enter image description here

could you help me to do so ? I don't want to use 9patch png ,is it possible to do so by using xml drawable?

mahdi yamani
  • 923
  • 3
  • 12
  • 29

3 Answers3

3

you can do it using layer list:

border.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <solid android:color="@color/WhiteSmoke"/>
        <corners android:radius="2dp" />
    </shape>
</item>

<item
    android:left="2dp"
    android:right="2dp"
    android:top="5dp"
    android:bottom="0dp">
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white"/>
        <corners android:radius="2dp" />
    </shape>
</item>

Where you can define how thick the border is in android:left,right,..

To use it on text view you must save it into res/drawable and then set the background of your text view to:

android:background:"@drawable/border"
1

You need to use the nine-patch to add such shadow, use the one attached here

enter image description here

Fahim
  • 12,198
  • 5
  • 39
  • 57
0

The android:layout_alignParentBottom attribute has to be declared in an element of the RelativeLayout.

Here is the sample code -

<RelativeLayout 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content"         
 android:layout_centerHorizontal="true">
  <ListView ...>
  <Button android:id="@+id/btnGetMoreResults"
   android:layout_height="wrap_content" 
   android:layout_width="wrap_content"     
   android:text="Get more"
   android:layout_alignParentBottom="true" />
</RelativeLayout>

HOpe this helps :)

Ashish Tamrakar
  • 810
  • 10
  • 24