Android图标mipmap值在按钮上不起作用
我试图得到一个在安卓系统上运行的带有图像的按钮。我尝试了以下方法:Android图标mipmap值在按钮上不起作用,android,android-mipmap,Android,Android Mipmap,我试图得到一个在安卓系统上运行的带有图像的按钮。我尝试了以下方法: <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:icon="@mipmap/ic_launcher" /> 按钮显示时不显示图像 试试看 <Button a
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@mipmap/ic_launcher" />
按钮显示时不显示图像 试试看
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />`
`
#。如果您想要一个只有背景的按钮
,请尝试以下操作:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:background="@mipmap/ic_launcher"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:drawableLeft="@mipmap/ic_launcher"/>
#。如果您想要一个带有文本和背景图像的按钮
,请尝试以下操作:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:background="@mipmap/ic_launcher"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
android:drawableLeft="@mipmap/ic_launcher"/>
你想把图像放在哪里?我只想要一个带有图像而不是文本的按钮。图像位于res/mipmap文件夹中,android studio在您导入图像资产后将其放在该文件夹中。除了应用程序图标,您不应使用
mipmap
文件夹。对于图形资源,请使用drawable
。这似乎可以解决问题。找到一个有点粗糙的解决方案,但已经足够了。谢谢如果答案有用,请接受。干杯