0

My app

Here, for the mixed button I have used

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <bitmap
        android:src="@drawable/stripes"
        android:tileMode="repeat"
        android:dither="true"
        android:antialias="true" />
</item>
</layer-list>

And for other buttons I have used

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle">
  <gradient android:startColor="@android:color/transparent"
    android:endColor="@android:color/transparent"
    android:angle="270" />
  <corners android:radius="3dp" />
  <stroke android:width="5px" android:color="#000000" />
</shape>

Now I want to add that black border around the mixed button how to do?

Susmit Laha
  • 23
  • 1
  • 6

2 Answers2

0

Use shape in layer list under item in xml file like below

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap
            android:src="@drawable/stripes"
            android:tileMode="repeat"
            android:dither="true"
            android:antialias="true" />
    </item>
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle">
            <gradient android:startColor="@android:color/transparent"
                      android:endColor="@android:color/transparent"
                      android:angle="270" />
            <corners android:radius="3dp" />
            <stroke android:width="5px" android:color="#000000" />
        </shape>
    </item>
</layer-list>

It'll help you..

reference How overlay bitmap and shape in layer-list properly

Community
  • 1
  • 1
ELITE
  • 5,815
  • 3
  • 19
  • 29
0

You are super close, you just need to add the Shape (for your border) to the <layer-list>

Something like this:

<?xml version="1.0" encoding="utf-8"?>

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap
            android:src="@drawable/stripes"
            android:tileMode="repeat"
            android:dither="true"
            android:antialias="true" />
    </item>
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle">
              <gradient android:startColor="@android:color/transparent"
                   android:endColor="@android:color/transparent"
                   android:angle="270" />
         <corners android:radius="3dp" />
         <stroke android:width="5px" android:color="#000000" />
      </shape>    
    </item>
</layer-list>
Booger
  • 18,579
  • 7
  • 55
  • 72
  • Thanks. But any idea how to add corners in the "@drawable/stripes" ?? Because of this, the corners of shape doesn't seem to work! – Susmit Laha May 13 '17 at 13:09