Android Image Button

android image button

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" />

Sample Image

Android: combining text & image on a Button or ImageButton

You can call setBackground() on a Button to set the background of the button.

Any text will appear above the background.

If you are looking for something similar in xml there is:
android:background attribute which works the same way.

Make borderless image button small on Android

You should use:

  android:background="?selectableItemBackgroundBorderless"

Difference in appearance of Button and ImageButton

Button has default elevation (actually, it has a StateListAnimator that provides elevation when the button is enabled) under the Material theme, whereas ImageButton does not.

Android ImageButton does not display image, even though it is visible in the Designer preview

try using only src instead of srcCompat and see if it works



Related Topics



Leave a reply



Submit