Are themes in android immutable? - android

I read in multiple places that themes are immutable. However, from this [method](https://developer.android.com/reference/android/content/res/Resources.Theme.html#applyStyle(int, boolean)) and this answer, I don't see how that is true. What do people mean when they say themes are immutable?

By immutable they mean that if you define a theme in a styles file, in XML, you cannot change its properties dynamically (programatically).
See the answer provided here: How to programmatically create an Android theme style?

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.

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.

What is the difference between R.style.x, and R.attr.x?

What is the difference between let's say android.R.style.TextAppearance_large and android.R.attr.textAppearanceLarge?
The attr part is just a thing which can been styled e.g. with a theme while that style is already one defined style.
So you can refer a style without knowing the style attributes. That is really helpful if you want to define a control which can been styled in multiple ways. Like for a button you have a holo style or some other device typical styles.
If you know C you can compair it with a prototype (or header file) while the style is the implementation.

Where can I find the values used in Android themes?

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.

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