I would like to have an android button with an image and not a background color but I can’t do it I always have the default color when I compile or even in the android studio view.
I would like to have an android button with an image and not a background color so I tried to put the path to my image directly:
with : android:background=”@drawable/button”
<Button
android:id="@+id/button"
android:layout_width="170dp"
android:layout_height="110dp"
android:layout_marginTop="136dp"
android:layout_marginEnd="124dp"
android:text="@string/button"
android:textColor="#05F192"
android:textSize="20sp"
android:background="@drawable/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
but when I compile or put the view on android studio there is always the pink color by default. I also tried to create an xml file that points to my image :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<bitmap android:src="@drawable/icon"
android:gravity="center"/>
</item>
<item>
<bitmap android:src="@drawable/icon"
android:gravity="center"/>
</item>
</selector>
but nothing changes, there is still the default color
TROY BAPTISTE miminbat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.