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>
Was it helpful?

Solution

Make your src image round, or make it transparent so you can see the rounded background behind it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top