-1

Possible Duplicate:
How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

I currently just have just a button with text in it but now I want to add a background image to it. But I don't want the background image to cover the whole button. I would like it to look something like the buttons in this picture. (Look at the picture under the app screenshots, it's the first image.) Here is a link to the picture.

https://play.google.com/store/apps/details?id=com.pxstudios.minecraftpro&feature=related_apps#?t=W251bGwsMSwxLDEwOSwiY29tLnB4c3R1ZGlvcy5taW5lY3JhZnRwcm8iXQ..

Community
  • 1
  • 1
user2005921
  • 39
  • 3
  • 6

3 Answers3

1

You mean the list view with the text to the right of the buttons? You use two views, a text view and an image view

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
    <ImageView ...>
    <TextView ...>
</LinearLayout>
Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • OK. thanks but is their any other way. Because I have at lease 200 buttons and thats going to be a lot of text – user2005921 Feb 05 '13 at 01:18
  • Create a new View subclass that consists of this layout. Then you can just declare it by name. Although if you have 200- you're probably going to throw it into a ListView? In that case, you'll be inflating it in code in the GetView function of your adapter and not putting 200 of them in xml. – Gabe Sechan Feb 05 '13 at 01:24
1

You can do something like this:

<Button
    android:id="@+id/button_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/[your_image]"
    android:text="Your_Text"
    android:textSize="48dp" //<==give a dimension to a text
    android:textStyle="bold"//<==is better your text is bold
     />

If u use Eclipse, use graphic editor to create how many buttons you wants, just copy and paste in your Xml file. And use Strings.xml to store your text.

Augusto Picciani
  • 788
  • 2
  • 11
  • 31
0

You can use android:drawableLeft attribute to set the icon to the left. Button is derived from TextView so it supports this attribute,

Ray
  • 16,025
  • 5
  • 31
  • 51