NikhilReddy
NikhilReddy

Reputation: 6954

How to align the ui for button?

I need to align the UI for a button, which I posted. I am not sure how to use Button or ImageButton. How do I align the image and text in a button?

<ImageButton
                    android:id="@+id/btnGroupDelete"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dip"
                    android:layout_weight="1"
                    android:background="@drawable/list_buttonselector"
                    android:contentDescription="@string/delete"
                    android:src="@drawable/ox_icn_delete" />

Upvotes: 1

Views: 150

Answers (3)

lomec
lomec

Reputation: 1354

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/image"
android:layout_gravity="center_horizontal"
android:paddingLeft="10dip"
android:text="@string/btntext" />

Upvotes: 1

MAC
MAC

Reputation: 15847

        <Button
        android:id="@+id/button1"
        android:gravity="right"  <----------
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

Upvotes: 1

Vij
Vij

Reputation: 78

Save image in drawable then use Image button in xml

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

For state change of button (pressed, focused, default), have a look at

http://developer.android.com/reference/android/widget/ImageButton.html

Upvotes: 2

Related Questions