0

How to remove bottom line/stroke from view ? I am using to set background xml file like

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<solid android:color="@color/inactive_tab" />

<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="8dp"
    android:topRightRadius="8dp" />
  <stroke
      android:width="2dp"
      android:color="@android:color/black" />
  <padding
      android:left="7dp"
      android:top="7dp"
      android:right="7dp"
      android:bottom="0dp" /> 
</shape>

but it has bottom line.

Martin Cazares
  • 13,637
  • 10
  • 47
  • 54
PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
  • You could layer another rectangle shape on top of the bottom area of above drawable, but that isn't ideal in terms of overdraw. A more appropriate solution would be to render the drawable out to a 9 patch and remove the bottom border. – MH. Sep 09 '13 at 22:11

1 Answers1

3

Use layer-list to layer other rectangle on top of the bottom rectangle. Try the following code:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <stroke
                android:width="1dp"
                android:color="#FF000000" />

            <solid android:color="#000000" />

            <corners
                android:bottomLeftRadius="0dp"
                android:bottomRightRadius="0dp"
                android:topLeftRadius="8dp"
                android:topRightRadius="8dp" />
        </shape>
    </item>
    <item
        android:left="5dp"
        android:right="5dp"
        android:top="5dp"
        android:bottom="-1dp">


        <shape android:shape="rectangle" >
            <stroke
                android:width="0dp"
                android:color="#FFDDDDDD" />

            <solid android:color="#FFDDDDDD" />


        </shape>
    </item>

</layer-list>

Related link: add_border

Community
  • 1
  • 1
Manishika
  • 5,478
  • 2
  • 22
  • 28