Arnav Mangla
Arnav Mangla

Reputation: 141

How to remove default background tint of button

I am new to android development and I came across this issue when I was trying to create a custom button. I have created a simple drawable and I set it as the background of my button. But that doesn't work, at least not directly, first i have to add app:backgroundTint="@null (which I got to know from here)

So what I want to do is set the default backgroundTint as 'null'. So where do I add this? Or any other way to achieve this?

Update:

I've found a solution to this and I've posted it.

Upvotes: 2

Views: 1182

Answers (2)

Inliner
Inliner

Reputation: 1659

You don't have to change your theme

you can just change materialButtonStyle parameter as I explained here: https://stackoverflow.com/a/74862273/12084802

Upvotes: 0

Arnav Mangla
Arnav Mangla

Reputation: 141

So, after a lot of researching and experimenting, I've concluded that the default purple tint on buttons is due to the themes.xml file. The Styles tag inside the themes.xml generally has this as the first line for me:

<style name="Theme.appName" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

Now the reason it uses the purple tint on buttons is due to the "parent". So changing the parent in the style tag of themes.xml to "Theme.AppCompat.Light.DarkActionBar" does the trick. It sets the plain grey button as the default button for that project which you might've seen in many tutorials

Upvotes: 2

Related Questions