I want to create a shape for buttons like this picture but I don't know how to use shape for creating a button like the picture.
I want to create a shape for buttons like this picture but I don't know how to use shape for creating a button like the picture.
UPDATE
OR you can just add the picture as the background.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/pic1" />
</selector>
Just define a layout for the button as the background insert, and you can change the effect you want.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="3dp" android:color="#ff000000" />
<corners android:topLeftRadius="0dp" android:bottomLeftRadius="30dp"
android:topRightRadius="0dp" android:bottomRightRadius="0dp"/>
<solid android:color="#ff0000"/>
</shape>
Try below background vector drawable for something like

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="80"
android:viewportHeight="100">
<group android:name="rotationGroup">
<path
android:pathData="M 5,5 L 75,5 75,25 12,25 5,16 5,5"
android:strokeWidth="1"
android:fillColor="#44008080"
android:strokeColor="#008080"
android:trimPathStart="0"
android:trimPathEnd="1" />
</group>
</vector>
You can create an SVG file and set it as background. Change it as per your requirement (color and path)
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="80"
android:viewportHeight="100">
<group android:name="rotationGroup">
<path
android:pathData="M 5,5 L 75,5 75,25 15,25 5,5"
android:strokeWidth="1"
android:strokeColor="#ffffff"
android:trimPathStart="0"
android:trimPathEnd="1" />
</group>
</vector>
You can search for .svg format of button like that, convert it into xml coding using online convertors and use that xml code in your application. Then you simply have to refer that xml file.
You don't need a custom shape as background.
Just use the MaterialButton with shapeAppearanceOverlay:
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
app:strokeWidth="1dp"
app:strokeColor="@color/..."
app:shapeAppearanceOverlay="@style/CustomShape"
/>
with:
<style name="CustomShape">
<item name="cornerFamily">cut</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeBottomLeft">50%</item>
</style>