android image button


Question

How can i create a button with no text and an image centered horizontally ? I don't want to use an ImageButton because I want to define a different backgound image

1
98
2/17/2010 6:42:48 PM

Accepted Answer

You just use an ImageButton and make the background whatever you want and set the icon as the src.

<ImageButton
    android:id="@+id/ImageButton01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/album_icon"
    android:background="@drawable/round_button" />

enter image description here

188
5/27/2019 11:08:12 AM

just use a Button with android:drawableRight properties like this:

<Button android:id="@+id/btnNovaCompra" android:layout_width="wrap_content"
        android:text="@string/btn_novaCompra"
        android:gravity="center"
        android:drawableRight="@drawable/shoppingcart"
        android:layout_height="wrap_content"/>

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon