0

I am trying to draw this shape in xml and I was hoping to just do it on an ImageButton this what I have

<ImageButton
     android:layout_width="48dp"
     android:layout_height="48dp"
     android:layout_alignParentTop="true"
     android:layout_marginStart="59dp"
     android:layout_marginTop="12dp"
     android:layout_marginEnd="30dp"
     android:alpha="0.14"
     android:layout_marginBottom="12dp"
     android:background="@drawable/round_background"
     android:src="@drawable/ic_location"
Maria
  • 377
  • 2
  • 15

1 Answers1

0

To use the attributs android:foreground on API 23 and lower you can create a style like below :

 <style name="MyImageButton" parent="Widget.AppCompat.ImageButton">
        <item name="android:foreground">@drawable/round_background</item>
    </style>

and just you need is to apply this style in your ImageButton :

 <ImageButton
     style="@style/MyImageButton"
     android:layout_width="48dp"
     android:layout_height="48dp"
     android:layout_alignParentTop="true"
     android:layout_marginStart="59dp"
     android:layout_marginTop="12dp"
     android:layout_marginEnd="30dp"
     android:alpha="0.14"
     android:layout_marginBottom="12dp"/>
Shay Kin
  • 2,539
  • 3
  • 15
  • 22