Android button background is taking the primary color

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

Leave a Comment