0

Here are my pics, It is the code in which i have written the color code

Here is android blueprint here the color doesn't change

I have tried many ways like adding through styles too it didn't work out. I have also tried to change background tint but it doesn't help either. how can i change the button color?
i have shared my code in pics above.
Help me to change color

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Aryan Kalekar
  • 21
  • 1
  • 5

3 Answers3

1

Just close the xml and reopen it. You will be able to find the defined color in your xml view. There is nothing to do with theme. Its just Android studio xml updation delay.

If it is not working then add below line to your Button tag

app:backgroundTint="your color code"
Priyanka
  • 1,791
  • 1
  • 7
  • 12
0

Add this to your drawable

<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle">

    <solid android:color="#156667"/>
    <corners android:radius="5dp"/>

</shape>

and apply it to your button's background in xml, you can change the color on <solid android:color="yourColor"/> there.

itsmebil
  • 155
  • 1
  • 9
0

Since you are using a Theme.MaterialComponents.* theme the Button is replaced with a MaterialButton and by default has the backgroundTint based on the colorPrimary defined in your app theme

Use the backgroundTint attribute to change your color.

You shouldn't use the android:background attribute to change the color but if you want to use it to define a custom background you have to avoid that the button is tinted using:

<Button
    app:backgroundTint="@null"/>

Also using the android:background attribute the MaterialButton doesn't use its own MaterialShapeDrawable for the background. This means that features like shape appearance, stroke and rounded corners are ignored.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841