skip to Main Content

So I just went into attributes in android studio to change the color of the button, just like I would the name of the button and other attributes. But now the color seems not to be taking effect when I compile and run on my phone.
I can only see the color change when I change the theme view but, I can not see it when I compile and send to phone.

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"  
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<Button
            android:id="@+id/btn_answer2"
            android:layout_width="wrap_content"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:background="#FA39D328"
            android:backgroundTint="#E10A0A"
            android:text="Button" />

This is the only options i have with theme, I can see the the color only on different themes but they do not show up when I run the app. Before changing attributes would change the color

This is the attributes change

2

Answers


  1. Remove android:background="#FA39D328", use only android:backgroundTint="#E10A0A".

    <Button
                android:id="@+id/btn_answer2"
                android:layout_width="wrap_content"
                android:layout_height="200dp"
                android:layout_weight="1"
                android:backgroundTint="#E10A0A"
                android:text="Button" />
    
    Login or Signup to reply.
  2. Use AppCompatButton

    
        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/click"
            android:background="#FA39D328"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/pay_now"
            app:layout_constraintBottom_toBottomOf="parent" />
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search