Estif
Estif

Reputation: 57

How do i get the button's color to change?

Here's my button in a fragment

<Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="login"
        android:background="@drawable/button_bg"
        android:textStyle="bold"
        android:textSize="16sp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintVertical_bias=".7"
        app:layout_constraintWidth_percent=".8"/>

And here's the applied background for the button

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp"/>
<solid android:color="#F82F5A"/>
</shape>

The button

The button remains unchanged

Upvotes: 0

Views: 46

Answers (1)

Put this code inside the Button tag :

android:background="<hex color>"

or:

android:backgroundTint="<hex color>"

Upvotes: 1

Related Questions