我正在尝试获取一个带有可在 Android 上运行的图像的按钮。我尝试了以下方法:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@mipmap/ic_launcher" />
该按钮显示没有图像。
我正在尝试获取一个带有可在 Android 上运行的图像的按钮。我尝试了以下方法:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@mipmap/ic_launcher" />
该按钮显示没有图像。
#. 如果你想要一个Button
只有背景的Image
,试试这个:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"/>
或者,您可以使用ImageButton
如下:
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
#. 如果你想要一个Button
withText
和 background Image
,试试这个:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:background="@mipmap/ic_launcher"/>
#. 如果你想要一个Button
withText
和 left drawable Icon
,试试这个:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:drawableLeft="@mipmap/ic_launcher"/>
尝试
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />`