我想要獲取帶有在Android上工作的圖像的按鈕。我嘗試了以下方法:Android圖標mipmap值不能在按鈕上工作
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@mipmap/ic_launcher" />
該按鈕顯示沒有圖像。
我想要獲取帶有在Android上工作的圖像的按鈕。我嘗試了以下方法:Android圖標mipmap值不能在按鈕上工作
<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" />`
這似乎是訣竅。找到解決方案有點怪異,但足夠。謝謝! – user1111652
接受答案,如果它有用。乾杯 – Akshay
#。如果你想與只背景Image
一個Button
,試試這個:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"/>
OR,你可以按照以下使用ImageButton
:
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
#。如果你想與Text
和背景Image
一個Button
,試試這個:
<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
和Text
左繪製Icon
,試試這個? –我只想要一個圖片而不是文本的按鈕。該圖像位於res/mmapmap文件夾中,在您導入圖像資源後,android studio會將其放入。 – user1111652
您不應使用除應用程序圖標以外的'mipmap'文件夾。對於圖形資源使用'drawable'。 –