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.

1
  • 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 9, 2013 at 22:11

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.