Where can I find the values used in Android themes? - android

Does anyone know how I can find out what values are set in different Android themes? I know how to find the names of themes in the Graphical Layout view for a layout resource (Theme.Black, Theme.Light, Theme.Holo.Light, etc).
I want to find out the margins, color values, padding, and all that stuff for the different themes so I can make my app look consistent across devices whether they have a particular theme available or not.

You can get the information regarding the theme from the
#android:style/
So please Do it in your style.xml in value directory and you will get the default value of the style.
You can also add your custom style for any behaviour like theme or textAppearance or anything you want.
Also refer this.
Just refer it and you will get that values.
Hope it will help you.
Enjoy. :)

I think if you want to find the themes in certain device, you should get the source code of this device or decompile the framework-res.apk can also get styles.xml and themes.xml file. A lot of devices have changed the default themes, so if you want to make your app looks the same in different devices, the best way i think is to add android:theme in your AndroidManifest and refer to a self-build theme which does not inherit the system theme.

Related

Is textAppearance and inbuilt theme attribute in Android?

I've been learning more concepts in Android and came across textAppearance.
android:textAppearance="?android:attr/textAppearanceLarge"
I did some research on this and came to the conclusion that this syntax refers to attributes in the Theme whereas # syntax refers to resources in the project / framework.
However, in my theme.xml file, I didn't define any item by the name of textAppearanceLarge. Therefore, I was wondering, is textAppearance and inbuilt item in the theme which Android provides?
Also, some background information on this topic would be really helpful.
Thank you!!
Yes textAppearance is inbuilt property of Android SDK.
TextAppearance allows you to define text-specific styling while leaving a View’s style available for other uses. Note, however, that if you define any text attributes directly on the View or in a style, those values would override the TextAppearance values.
TextAppearance supports a subset of styling attributes that TextView offers. For the full attribute list.
You can also read the following blog by Google developer to understand it in deep.
https://medium.com/androiddevelopers/whats-your-text-s-appearance-f3a1729192d
And also can refer to google documentation to understand the technical aspect of it.
https://developer.android.com/guide/topics/ui/look-and-feel/themes#textappearance
Use ctrl+ mouse_left_cllick to explore .......basically, it will direct you to the exact code.

Description of Material Components themes?

I am currently getting started with Material components themes. The Getting Started guide mentions these themes:
Theme.MaterialComponents
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.DarkActionBar
Theme.MaterialComponents.DayNight
Theme.MaterialComponents.DayNight.NoActionBar
Theme.MaterialComponents.DayNight.DarkActionBar
There is no description for them though. Where can I find more details about those themes or could anyone be so kind to explain them in an answer? Just for example:
What means [..].NoActionBar? If I don't want an action bar, I don't include it in my layout file, so I really don't get this.
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
How do these themes look like? I couldn't find any preview and don't want to try them all out by myself - could take some time with all the widgets available on Android.
What do these themes define? Only colors? Text style? Font family?
I'm certain that I won't manage to answer all of your questions exhaustively but I'll share some thoughts, maybe it will take you one or two steps further:
What means [..].NoActionBar?
You should use a theme ending with ".NoActionBar" if you don't want the runtime to add an ActionBar to the Activity, possibly because you use a Toolbar. If you choose for example Theme.MaterialComponents.Light and use a Toolbar as well, you will notice that now your app will be renderd with two ActionBars
Please note that if some theme is called "MyTheme" then a theme which is prefixed by "MyTheme." will inherit everything from "MyTheme". So Theme.MaterialComponents.Light.NoActionBar is almost the same as Theme.MaterialComponents.Light except for the ActionBar.
So if you really don't want any ActionBar you should choose the .NoActionBar version and not include a surrogate (Toolbar) in your layout files.
What do these themes define? Only colors? Text style? Font family?
They do that, but they define also sizes, margins and behavior. In addition to that, some of them have special style combos for certain widgets (like style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox" for TextInputLayout)
For a deep dive into what properties can be influenced by a theme, you can take a look at the source of themes_material.xml
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
Since Theme.MaterialComponents is the parent theme of Theme.MaterialComponents.Light, they have much in common. The main difference is that the first assumes that your app will have a dark background (so the text should be white) whereas the second will have black text and assumes your app's background will be light.
Generally, one will try to use a certain theme as a template which then can be/ has to be customized - for example with a special accent color.
How do these themes look like?
You can get a general idea by switching from one to the other in a small sample app of your own.
It's true that there is not one single source of information (aka the android theming bible). You have already found material.io, but maybe the Styles and Themes section from developer.android.com or this blog post on DayNight — Adding a dark theme to your app will shed some more light.

Override a style in Android without modifying layout file

My experience up until now when dealing with styles has been to create a style.xml file and create the properties I want for the style. If I want my style to be based on an existing style, I use the parent attribute. I then specify the style inside of my layout file on the controls that I want to apply the style to.
Where I am at a loss is when I want to use system styles and only update certain properties. I am wondering whether I can leave the layout files alone and not bother applying any styles to the controls. Instead, I would somehow update the property of the system style and that would update everywhere in my app where that style is already being used by default.
More specifically, I want to change the background color of the Actionbar but haven't found a way of doing it other than the way I described above.
You're probably looking for themes, which are collections of styles, applied either globally throughout the application, or for each Activity in particular. Start with this document and investigate further.

Where can I find all Android built in themes

At the moment im using:
android:theme="#android:style/Theme.Black.NoTitleBar"
Which I'm growing a bit bored of, Is there a link you can direct me to that shows me examples of all the inbuilt themes and their names?
I read on another post that there is quite a few so it would be best if there was a website/other source that could show me some previews :)
Thanks for the help!
Your IDE (I know Android Studio does), should show you them.
Otherwise, here they are in raw xml form. https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
More information on Android Dev docs: http://developer.android.com/guide/topics/ui/themes.html
You can see all the theme names in the manifest.xml. For this see the following snapshot:
Android Studio has a Theme Editor which provides preview function.
User can find all built-in themes inside.
2 ways to open it:
Open a styles XML file, for instance res/values/styles.xml. Then click Open editor near the top-right of file-editing window.
in top menu bar Tools-Android-Theme Editor.
I'm pretty noobish with it all but basically I think there are only two themes. Day/Night and Light. You can select individual parts and change them but as far as I can tell there are only two themes.
As I had a comment that said this doesn't answer the question I will add that you can use Theme.AppCompat.DayNight or Theme.AppCompat.Light in the AndroidManifest.xml or in styles.xml and edit any individual attribute but there are about a million attributes and god only knows what they all do. In my opinion it's a massive oversite by android.

Android easy switch color-scheme of application

How would you implement different color themes in your app?
All I can see now is plain set color onCreate every activity and control...
Also, how would you store different color schemes in xml?
Just an entries of with different names?
Thank you!
Use custom Themes, which are declared in XML. They are very similar to CSS, if you've used them before.
EDIT:
Here's a better example of changing the theme at run time

Categories

Resources