Android button background is taking the primary color

Solution 1:

Since you are using a Theme.MaterialComponents.* your Button is replaced at runtime by a MaterialButton.

Currently the backgroundTint is still the default MaterialButton style. It means that if you are using a custom android:background, you have to make sure to null out backgroundTint to avoid that the custom background doesn't get tinted with the attr/colorPrimary defined in your theme.

You have to add app:backgroundTint="@null":

  <Button
    app:backgroundTint="@null"
    android:background="@drawable/.."

In any case you don't need a custom background (btn_rounded_stroke) in your case. You are just using a custom background only to define rounded corners. This feature is provided by default by the MaterialButton, then just use the cornerRadius attribute.

Use the standard MaterialButton:

    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        style="@style/Widget.MaterialComponents.Button.OutlinedButton"
        app:strokeColor="#59CECE"
        app:cornerRadius="24dp"

enter image description here

Solution 2:

When Material theme is used then Button view is mapped to MaterialButtton. There is one more way to setup the button background in this case.

    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar"
...
        <item name="materialButtonStyle">@style/ColoredButton</item>
    </style>

    <style name="ColoredButton" parent="Widget.MaterialComponents.Button.TextButton">
        <item name="backgroundTint">@color/customButtonColor</item>
    </style>