What makes buttons purple in Android studio? Plus other odd behaviours for a newbie


In web development, I see how tags have default themes defined in the browser, and I see how they’re applied.

However, with Android studio’s themes, I’m really confused. I can define my custom themes using ?attr/myClass and then apply it on widgets by android:theme="?attr/yClass", then assign a colour to that attribute in my day or night theme files.

But, what baffles me, is- that purple. Where does it come from? When I set the theme header to

<style name="Theme.TestingThemes" parent="Theme.MaterialComponents.DayNight.NoActionBar">

purples come for the not night mode.

  • When I use other styles that come with "default" with Android studio, I don’t see exactly that purple.

  • Some themes allow me to set my own colours, but some others don’t, like the one that I mentioned.

  • Worst of all that totally blows my mind is: when I open the theme files in app/res/values/themes/* and app/res/values/colors.xml*, I only see less than 10 themes defined. Yet I see Android studio suggesting to me a long list of colour names! Where do these come from?

I’m facing my 1st mobile development task, and really frustrated. I only use vim as my text editor. I’m drowning in Android studio. It’s cool and powerful, but I require some baby-walking assistance. S.O.S.


A default new project created in Android Studio has a colors.xml resource provided in the project (res/values/colors.xml), where the purple_500 and purple_700 you described are defined.

Any other colors and themes you see that aren’t in your own project’s files are in the AppCompat and Material Components libraries (defined as project dependencies in default new projects), or they’re built into Android itself.

In the Projects panel on the left in Android Studio, if you expand External Libraries, you can see all the code libraries that are imported for your project as dependencies (these are defined in app/build.gradle and downloaded from the Web automatically). Among these dependencies are AppCompat and possibly the Material Components libraries, with their own provided resources within.

You can’t modify the contents of the libraries. You’re intended to customize by extending (making child styles and themes).

If you want to see where a reference is defined in Android Studio (in XML or other languages like Kotlin and Java), you can Ctrl+Click and it will jump to the line that defines it in whatever file it’s in.

Answered By – Tenfour04

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published