-6

Possible Duplicate:
How to show the text on a ImageButton?

what is wrong with the xml, I can not see my text on the button

    <ImageButton
    android1:id="@+id/btnShowLocation"
    android1:layout_width="wrap_content"
    android1:layout_height="wrap_content"
    android1:layout_alignParentBottom="true"
    android1:layout_centerHorizontal="true"
    android1:contentDescription="@string/empty"
    android1:layout_marginBottom="40dp"
    android1:src="@drawable/blue_button"
    android1:background="@null"
    android1:text = "@string/here_and_now"
    android1:textColor="@string/black_color"
    android1:gravity="center"
   />
Community
  • 1
  • 1
Muhammad Irfan
  • 1,447
  • 4
  • 26
  • 56

2 Answers2

3

you can't use android:textfor the ImageButton. so just use a button and set background for it.

For example:

<Button 
   android1:id="@+id/btnShowLocation"
   android:layout_height="wrap_content"
   android:layout_width="wrap_content"
   android:layout_gravity="center"
   android:padding="10dp"
   android1:text = "@string/here_and_now"
   android:background="@drawable/blue_button"/>
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
-1

I can't find android:text property under ImageButton tag.

You should rather use a button and use "background" property to put an image on a button.

<Button android:id="@+id/friendsListButton" android:gravity="center"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:text="@string/friendsListScreen" android:background="@drawable/blue_button"/>

If you want an image on the button, just define it as above.

Yogesh Somani
  • 2,624
  • 3
  • 21
  • 34