
To elaborate, let’s see the example of Theme.Holo :. Definition of a theme is in the essence jsut a collection of references to stlyes that the theme will use. There are more styles than themes (Checkout styles.xml and themes.xml). We set a style in a layout file or a widget.
We set a theme in the Manifest of the app or an activity. A theme is infact a style, the only difference is the usage. I was also not totally clear about this until recently. They get confused on what is the difference between them. This is a topic which most of the developers don’t know about. This makes the button consistent with guidelines and the app looks perfect. So For example I want a button to be Holo until kitkat and then Material starting Lollipop, I’ll do something like this : you don’t need to worry about the variations but when you want to style something not in AppCompat, then the main problem arises. If you’re using something that’s part of the AppCompat, then it’s okay. If you want to define the default button for all of your payment screens in the example above, you can do something like : īut note that if you’re tweaking the default style, the only tricky part is to figure out the parent of your style but that’s really dificult due to a lot of variation within the different versions of android. Themes provide a way of defining the default style of many widgets. Try to use themes to tweak default styles Hence we make the Buttons follow one particular style You need similar kind of buttons there to make it look like a continuous process. You want to get the user through a bunch of ordering and payment screens. When you have multiple views that should look identical ( Perhaps that do similar things) Now I am going to show the rules that I follow: This shall be a long post! When should we use stylesįirst of all, most of us get confused on when should we use styles instead of an inline attribute.
So, I’ll be talking about styling different views in this post. This was for the Open Event android project where we wanted that while generating an apk by the apk generator we could change the color scheme of the app and could make it customisable for the needs of the organisations.
I had to change the whole app’s style’s and theme by just changing the colors etc. How often did you want to change a style but feared you might break the continuity of the design of the app somewhere or the other. The hierarchy easily devolves into spaghetti code. We tend to get frustrated when we work with them. Working with Styles and Themes in AndroidĪll thos wo have worked with styles and themes know that they’re hard to get right.