I created TableLayout
then buttons. The button's color was automatically set purple. So I can't change them right now. It's my first time here.
don't use anything else use
<androidx.appcompat.widget.AppCompatButton
<!-- attributes-->
/>
instead of one
<Button
<!--attributes-->
/>
every thing will work nicely.
Happy coding.
Android default color is Purple in the latest Android Studio version. To change the color of the Button, you need to add a single line of code in the XML i.e.
app:backgroundTint="@color/red"
That's all!
It's purple because of default background Tint color. You can : change **app:backgroundTint ** instad of android:backgroundColor . In this case your backgroundTint will appear instead of background color
OR
add
app:backgroundTint="@null"
and after that your background color will appear.
OR
You can change the default theme in android manifest . For example :
android:theme="@style/Theme.AppCompat"
or
android:theme="@style/Theme.AppCompat.NoActionBar"
Add the attribute:
app:backgroundTint="@null"
You might be using targetSdkVersion
30
Solution: change the theme.xml style from
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
to
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With