-1

I need to create a drawable shape XML as per the below image in which we have a triangle in the middle of the upper side.

The image needed to draw

I do know how to create a rectangle and a triangle

Rectangle drawable

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="2dp" android:color="#ff207d94" />
<padding android:left="2dp"
    android:top="2dp"
    android:right="2dp"
    android:bottom="2dp" />
<corners android:radius="5dp" />
<solid android:color="#ffffffff" />
</shape>

Triangle drawable

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
    <rotate
        android:fromDegrees="45"
        android:toDegrees="45"
        android:pivotX="-40%"
        android:pivotY="87%" >
        <shape
            android:shape="rectangle"  >
            <stroke android:color="@android:color/transparent" android:width="10dp"/>
            <solid
                android:color="#000000"  />
        </shape>
    </rotate>
</item>
</layer-list>

How to use both of them to create that image?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
WISHY
  • 11,067
  • 25
  • 105
  • 197

1 Answers1

2

It seems a 9 patch like this small thingy here

enter image description here

can really be what you are looking for:

enter image description here

Just give it the .9.png extension.
For a nice guide on 9 patches, see: http://radleymarx.com/blog/simple-guide-to-9-patch/

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • I agree, you could do it with a xml drawable but that doesn't guarantee that is going to look good in every device – 4gus71n Jan 05 '16 at 19:34
  • And I guess it would be a little harder to find the perfect receipt to it. And possibly also harder in rendering terms, maybe. – Phantômaxx Jan 05 '16 at 19:44