Make Circular Button with Border

You can use a MaterialButton

        <com.google.android.material.button.MaterialButton
            android:layout_width="50dp"
            android:layout_height="50dp"
            style="@style/Widget.App.Button.OutlinedButton.Icon"
            app:icon="@drawable/...."
            app:strokeColor="@color/..."
            app:iconSize="24dp"
            app:iconGravity="textStart"
            app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.MyApp.Button.Circle"
            />

with this style:

<style name="Widget.App.Button.OutlinedButton.Icon" parent="Widget.MaterialComponents.Button.OutlinedButton.Icon">
    <item name="android:padding">0dp</item>
    <item name="iconPadding">0dp</item>
    <item name="android:insetTop">0dp</item>
    <item name="android:insetBottom">0dp</item>
    <item name="android:insetLeft">0dp</item>
    <item name="android:insetRight">0dp</item>
</style>

and this shapeAppearanceOverlay:

<style name="ShapeAppearanceOverlay.MyApp.Button.Circle" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">50%</item>
</style>

enter image description here


For your button use this

<Button
 android:id="@+id/yourbuttonname"
 android:text="Button"
 android:textColor="#FFFFFF"
 android:textSize="30sp"
 android:layout_width="100dp"
 android:layout_height="100dp"
 android:background="@drawable/buttonshape"
/>

And create a buttonshape.xml file like this

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="rectangle" >
<corners
android:topLeftRadius="100dp"
android:topRightRadius="100dp"
android:bottomLeftRadius="100dp"
android:bottomRightRadius="100dp"
/>
<solid
android:color="#"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="100dp"
android:height="100dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape>

Just adjust the values of colors and the text you want.Enjoy!!


You have to create drawable for oval shape. Like this

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
        <solid android:color="@android:color/transparent"/>
        <stroke android:color="#fff" android:width="3px"/>
    </shape>

And then in your xml layout set background to that drawable

android:background="@drawable/your_drawable"