-6

重複の可能性:
ImageButtonにテキストを表示する方法は?

xmlの何が問題になっていますか、ボタンにテキストが表示されません

    <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"
   />
4

2 に答える 2

3

android:textImageButtonには使用できません。ボタンを使用して背景を設定するだけです。

例えば:

<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"/>
于 2012-10-25T11:32:52.117 に答える
-1

ImageButtonタグの下にandroid:textプロパティが見つかりません。

ボタンを使用し、「background」プロパティを使用してボタンに画像を配置する必要があります。

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

ボタンに画像が必要な場合は、上記のように定義してください。

于 2012-10-25T11:37:09.287 に答える