Ruby prO Ruby prO - 1 month ago 8
Android Question

Assigning an image to a button in Android

I have created an Android app in which I used two buttons and for those buttons I have designed images to fill the button's width and height properly.

I have saved the image as

PNG
With width and height 1000 x 1000 pixels respectively but when I applied those images to a button its resolution is pretty messed up. Following is the image I designed for my button


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