2

Friends,

I want to display a button in android like mentioned in screenshot.

Could anyone guide me through how to achieve this?

enter image description here

Kaarel
  • 10,554
  • 4
  • 56
  • 78
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
  • possible duplicate of [Android: combining text & image on a Button or ImageButton](http://stackoverflow.com/questions/1532876/android-combining-text-image-on-a-button-or-imagebutton) – Kaarel Jun 06 '11 at 14:40

4 Answers4

3

Use a normal Butto with drawableLeft attribute. See my sample code:

<Button android:layout_width="100dip" 
    android:layout_height="wrap_content"
    android:text="Refresh"
    android:drawableLeft="@drawable/ic_btn_refresh"
    android:id="@+id/btn_refresh" />
anticafe
  • 6,816
  • 9
  • 43
  • 74
1

You could use 9-patch fot background. You can specify padding area there (bottom and right lines), so background will be stretchable while text will not cover image. :)

woodshy
  • 4,085
  • 3
  • 22
  • 21
0

There is the ImageButton which you can use for that.

But I'm not sure how to make the Text on the button look like the Text in your screenshot. I would simply create the image with the text and then use it for the ImageButton.

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
  • If you have images with text on them, then maintaining and localizing them becomes a hassle. – Kaarel Jun 06 '11 at 14:35
  • You can create Images for every supported language and if those images are just for some buttons, the shouldn't be to large. – Lukas Knuth Jun 06 '11 at 14:38
0
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/refresh"
android:text="Refresh"/>
mysuperass
  • 1,199
  • 1
  • 9
  • 10