In code, a developer can set a theme using activity.setTheme(R.style.Theme_MyApp) and apply an "overlay" to override select values using activity.getTheme().applyStyle(R.style.ThemeOverlay_SeasonalUpdate, true).
Is there any way to define a theme in XML that extends Theme.MyApp and applies ThemeOverlay.SeasonalUpdate. I would love to do this in XML instead of applying the theme programmatically.
Related
Every time I go to xml file I've to change my theme first to see how my views will actually look, my parent theme is inheriting from MaterialComponents theme and all of the activities are using the same base theme, but still I don't know why in xml it shows Material.Light as my default theme.
and AppTheme is the theme that I want to set to default, is there any way I can do that.
To set or change the default theme, open AndroidManifest.xml and in the application tag, set if not exist or change
android:theme="#style/Material.light"
to whatever you want. You can change theme of individual activity by adding same line in the Activity tag of any Activity.
I have to declare some base values for my App (like windowNoTitle).In some activities the Theme.AppCompat.Light theme is needed cause of transparent background images. They need a white background but `` In others the Theme.AppCompat theme will be used for styling.
My App uses androidx.appcompat.widget.Toolbar. So I need to extend a Compat theme. I can't apply the default values as parent and apply the style via theme name.
How to apply the default values to both themes but not repeat my self. Is it possible to declare "style variables"?
Thanks in advance
Is there anyway to change theme attributes dynamically? For example,set the "android:colorPrimary" attribute for a Theme. I know I can apply different Themes to Activity when it creates, but it requires predefined styles in resources, which means the attributes are fixed. If I want to download one Theme from server(it can be a config file with some color attribute defined), this can't work out.
I'd like to dynamically change attributes in this theme: Theme.AppCompat.Light.DarkActionBar. In particular, I'd like to change the colorPrimary, colorAccent, and colorPrimaryDark attributes based on the data being displayed so that particular widgets like EditTexts can be themed appropriately. I know that I'd have to change the theme before setContentView(...) of my Activity but how do I change particular attributes in the theme before I do that?
Edit: From #reVerse's comment linking to this post I know that it's impossible to change a Theme as they are immutable. Is it possible to create a Theme programmatically?
I created an application where I applied theme Theme.Holo.Light. Now I want to change look of my edittexts and dialogs in PreferenceActivity to look like in Theme.Dark. How can I apply different Theme to this particular Widgets?