I need a round image-button which clips the image in a circle, but this is what I get->(see the bus image)->bus image
I have given the description of Imagebutton xml and shape xml. The image is not clipped in a round circle, but it appears that the circle is divided into 2 parts and image is added in the middle. My code is as below->
CODE:
layout/activity.xml:
<ImageButton
android:id="@+id/imageButtonGenerateBulk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:background="@drawable/drawii2"
android:src="@drawable/bus"
android:layout_weight="1"/>
drawii2.xml:
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="40dp" />
<gradient
android:angle="45"
android:endColor="#01f1fa"
android:gradientRadius="41dp"
android:startColor="#0189ff"
android:type="linear" />
<!--android:centerX="float"
android:centerY="float"-->
<!--If your shape requires only one solid color-->
<!--<solid
android:color="#FFFFFF" />-->
<size
android:width="30dp"
android:height="30dp" />
<!--Use android:dashWidth="2dp" and android:dashGap="2dp"
to add dashes to your stroke-->
<stroke
android:width="2dp"
android:color="#FFFFFF" />
<!--If you want to add padding-->
<!-- <padding
android:left="10dp"
android:top="20dp"
android:right="40dp"
android:bottom="8dp" />-->
</shape>
used this also:
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#0000" />
<corners android:radius="20dp" />
<size
android:width="10dp"
android:height="10dp" />
</shape>