Issue
I am trying to set the border and background, respectively black and white, of a button in Android. The border gets set, however the background of the button remains purple. What am I doing wrong with the background?
My shape file is called button_border_drawable.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/white" />
<stroke
android:width="1dip"
android:color="@color/black" />
</shape>
Here is my button
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_label"
android:textColor="@color/black"
android:background="@drawable/button_border_drawable">
</Button>
Theme:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Operator" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
Solution
The issue was solved by using the Theme.AppCompat.DayNight
theme.
Answered By - Hendré
Answer Checked By - Senaida (JavaFixing Volunteer)