or levi
or levi

Reputation: 31

button background color is always purple in android studio

I am coding in android studio for some months and everything worked great. In the last 2 weeks I updated android studio and since then, every time I put a button its color is defined as purple no matter what I am doing, even if I change its background. I tried to change it from the xml and also from the java file but without success. If someone knows how to change it, it would be very helpful. Thanks for answers.

the color of the button

Upvotes: 3

Views: 8193

Answers (4)

ahmadreza gh
ahmadreza gh

Reputation: 1

In Value/Themes/Themes.xml Instead of use Material3, use AppCompat

for example if you want this theme "Theme.Material3.DayNight.NoActionBar" use this "Theme.AppCompat.DayNight.NoActionBar"

Upvotes: 0

jackgrealish
jackgrealish

Reputation: 1

Change the theme.xml

style name="Theme.PROJECTNAME" parent="Theme.AppCompat.Light.NoActionBar">

Then the button without background will become grey and can be edited by color and drawable

Upvotes: 0

teynon
teynon

Reputation: 8288

Setting the app:backgroundTint to the color or transparent as well fixed this for me.

Upvotes: 1

Magdy Mostafa
Magdy Mostafa

Reputation: 41

Instead of button use <androidx.appcompat.widget.AppCompatButton>

Upvotes: 4

Related Questions