Answer the question
In order to leave comments, you need to log in
Why doesn't the button in xml change color?
My problem is this. I want my button to be black with a white stroke.
I made a separate xml file where I wrote everything.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false" >
<solid android:color="@android:color/black" />
<stroke
android:width="5dp"
android:color="@android:color/white" />
</shape>
<LinearLayout
android:id="@+id/fabWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_background"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:padding="5dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.QuitSmoking" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
</style>
<style name="Theme.QuitSmoking.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.QuitSmoking.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.QuitSmoking.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Answer the question
In order to leave comments, you need to log in
I solved the problem. Removing all the themes created by the studio. They didn't let me set the color
So you set the background not to the button, but to the linear layout in which it lies for some reason. Set button.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question