1

Right now I have this button using Shape Theming which I got from this thread.

Android: Make a button with triangle shape using xml definitions (drawable)

Code:

<style name="ShapeAppearanceOverlay.Button.Triangle" parent="">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSizeTopLeft">4dp</item>
        <item name="cornerSizeBottomLeft">4dp</item>
        <item name="cornerFamilyTopRight">cut</item>
        <item name="cornerFamilyBottomRight">cut</item>
        <item name="cornerSizeTopRight">50%</item>
        <item name="cornerSizeBottomRight">50%</item>
</style>

But I need the rounded edges like this button on all the corners of the triangle

enter image description here

Thank you very much

gidds
  • 16,558
  • 2
  • 19
  • 26
Patrick
  • 1,629
  • 5
  • 23
  • 44
  • Ask the graphic designer for this background vector image. – Sam Chen Feb 23 '22 at 19:49
  • I understand that this is not an option because the final part of the button, of the triangle, must always have the same width. What should be variable is the rectangular part. – Patrick Feb 24 '22 at 10:07

1 Answers1

0

Add shape

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

<item android:width="150dp" android:height="50dp" android:right="6dp">
    <shape>
        <solid android:color="@android:color/holo_green_dark"/>
        <corners
            android:bottomLeftRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="4dp"
            android:bottomRightRadius="3dp"/>
    </shape>
</item>

<item android:width="35dp"
    android:height="35dp"
    android:left="148dp">
    <rotate android:fromDegrees="44"
        android:pivotX="0"
        android:pivotY="0">
        <shape>
            <solid android:color="@android:color/holo_green_dark"/>
            <corners
                android:topLeftRadius="2dp"
                android:bottomLeftRadius="1dp"
                android:topRightRadius="5dp"
                android:bottomRightRadius="2dp"/>
        </shape>

    </rotate>
</item></layer-list>