Reputation: 59
I want to add an icon in my Button, but for the style of my button, I use a shape that defines my background color. I can't add the icon in the button, and I don't know if I should add the icon in the xml activity or in my shape?
My button :
<Button
android:id="@+id/button4"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.1"
app:layout_constraintVertical_bias="0.1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/btn_option"
/>
My shape :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#F06A73" />
<corners android:radius="50dp"/>
</shape>
Here, I only have the background color, and I can't add my icon (drawable/icon_option.png) the icon on it.
Can you help me?
Thanks!
Upvotes: 1
Views: 1110
Reputation: 619
Copy an image into the resources folder .go to the pallets and select the "image button" ...drag the image into your layout ....when you let go of the mouse ,the Resources Dialogue box will appear ,select OK and you should see the image in the button
Upvotes: 1