Make your src
image round, or make it transparent so you can see the rounded background behind it.
Android ImageButton src overwriting background
-
14-07-2023 - |
Question
I'm trying to create a rounded image button using the code below which works when you don't declare a src image. However when you do, it just places the image in but without the rounding effect on it.
style.xml
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/imageButton1"
android:layout_centerHorizontal="true"
android:layout_marginTop="41dp"
android:src="@drawable/ellyfish"
android:background="@drawable/roundcorner"
/>
roundcorner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#33DDFF" />
<corners android:radius="50dp" />
</shape>
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow