Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android图标mipmap值在按钮上不起作用_Android_Android Mipmap - Fatal编程技术网

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
。这似乎可以解决问题。找到一个有点粗糙的解决方案,但已经足够了。谢谢如果答案有用,请接受。干杯