user22677964
user22677964

Reputation:

Button drawable background

I want to change the button background using a drawable. The problem I have is that the button did not chang properly.

Gradient button.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient
        android:angle="45"
        android:endColor="@color/primaryYellow"
        android:startColor="@color/primaryGreen"
        android:type="linear" />

    <corners android:radius="20dp" />

</shape>

Button I'm applying the drawable:

<Button
            android:id="@+id/btnAll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/gradient_button"
            android:fontFamily="@font/montserrat_italic"
            android:text="@string/all"
            android:textAlignment="center"
            android:textColor="@color/darkNeutral"
            android:textSize="20sp"
            app:layout_constraintEnd_toStartOf="@+id/btnFavorites"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

I tried to apply android:backgroundTint property with the same drawable which lead to a build error.

Upvotes: 0

Views: 25

Answers (0)

Related Questions