I would like to deploy my app on APIs 8-17. However, for purely aesthetic reasons I would like to apply the default theme as it appears on api 8 as the theme for the app across all API levels.
For example, the older theme has an edittext that has an orangeish border around it, whereas the newer them uses a borderless blue line.
By limiting which APIs i deploy too I have been able to accomplish this but that isn't really a solution.
Does anyone know how this can be accomplished?
Thanks
Update
For whatever reason applying "Theme" as the theme did not force it to revert to the "Theme" theme, but instead left it as the default Holo. Using the answers below I simply called "Theme" as the parent in my custom theme (without altering any of its attributes) and set it as my application theme in the manifest. This solved it.
In your res/values directory, you can have a themes.xml file with:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="#android:Theme">
</style>
</resources>
Your app theme will now subclass from default Theme instead of Theme.Holo and you should be able to get older theme on newer android versions as well.
If you're using the default theme, it will be different between the API levels. However in the styles, you can create a custom Theme, modify an existing Theme or give a different Theme to each different API of your choice.
Related
I've added dark theme support for my application using 2 different themes declared in styles.xml.
On official android developer site:
In order to support Dark theme, you must set your app's theme (usually
found in res/values/styles.xml) to inherit from a DayNight theme
and this is what I've done. I've also created colors-night.xml to avoid modifying colors that cannot be modified in styles.xml by coding and this works too: when dark mode is activated from device system, colors changes automatically.
At this point, I was wondering which is the best way to implements dark theme: creating 2 different themes, using colors-night (and drawable-night) or a combination of these 2 ways?
First up is the youtube video below pretty much tells you what the current best practices are with regards to theming.
https://www.youtube.com/watch?v=Owkf8DhAOSo
They talked about splitting your styles into
themes.xml -> theme related styles
styles.xml -> component related styles
type.xml -> text appearances styles
All your colors should then be in one colors.xml which lives in values.
You will then have the following structure:
values/themes.xml
values/colors.xml
values/type.xml
values/styles.xml
values-night/themes.xml
In practice, I find that it is still hard to contain all the colors in just one colors.xml. I still create values-night/colors.xml as some colors don't necessarily fall into a style.
See this in practice in this repo. Observer that Google themselves didn't follow their point on just using one colors.xml.
https://github.com/material-components/material-components-android/tree/master/material-theme-builder
I have been developing an Android app for quite some time now and almost everything is how it's supposed to be. However, I'm having some issues with themes for some views. My application uses a AppCompat.Light based theme as shown bellow:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar"></style>
Everything looks white and clean, but I have one specific screen that is kind dark. So I created the following theme for some EditText fields:
<style name="InputField" parent="Theme.AppCompat"></style>
in order to make the input fields have white colors. I then run the application on devices with different Android versions. On a smartphone with Android 5.0.2, everything looks as I expected. On a smartphone with android 4.4.4, however, the input is dark. I even tried to change the theme of the input field theme to
<style name="InputField" parent="Theme.Holo"></style>
or
<style name="InputField" parent="#android:style/Widget.Holo.EditText"></style>
in the values-v19 styles, but it still looks dark. If I change the application theme to
<style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar"></style>
the input fields look as they should, but the entire rest of the app is dark themed and it's not what I want. I can only assume that application theme is having some influence over my views theme, even though I explicitly specified the theme they should use. The same behavior happens on a smartphone with android 4.2.2.
System provided styles doesn't define used colors, they have only references to a theme attributes. Colors are defined the theme, thus, it not enough, if you set parent to some system style.
Starting API 21 (5.0) you can override theme for specific views (or styles) by setting attribute android:theme. For older versions you will need to define specific colors and drawables in your style.
After setting SeekBar with Holo style, I got warning that it's not supported pre-Holo APIs.
If I leave it this way, will this crash the app or pull pre-Holo style anyway? It does not crash on the emulator and I don't have 2.3.3 device.
The reason for asking his is odd behaviour. I tried to manually set style for Holo and pre-Holo using res/values-v11/ directories and placing styles.xml in each and setting the style of SeekBar to style="#style/settings_seekbar" .
Style for API 11+ looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.Holo.SeekBar</item>
</style>
and style for APIs older than 11 looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.SeekBar</item>
</style>
So it looked like this would work. But on either device with Android 4.0+, I don't see Holo's theme, but the old thick-yellow theme.
If this is the proper way of settings styles (in case the first solution will crash a device), where did I make a mistake thus Holo theme never appeared on newer devices?
It seems we can safely use a theme from the upper SDK because I found no indicators that it will ever crash the app.
If the theme does not exist, Android will use the appropriate lower-level theme.
The error we can see on the image is just a warning that UI will not look the same in the SDKs which do not support this theme.
perhaps I don't know how to search for that - everything I found only is about changing the app theme.
I want to know how I can develop a whole theme for the android device itself?
On the market you'll find many themes out there - how can I build one, too?
I don't want to use 3rd party licences (ThemeMaker etc)...anyone who has a tutorial for me?
Thanks for your help!
You should read up on the Android Developer site - Styles and Themes http://developer.android.com/guide/topics/ui/themes.html
A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.
Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
Apply a theme to an Activity or application
To set a theme for all the activities of your application, open the AndroidManifest.xml file and edit the <application> tag to include the android:theme attribute with the style name. For example:
<application android:theme="#style/CustomTheme">
If you like a theme, but want to tweak it, just add the theme as the parent of your custom theme. For example, you can modify the traditional light theme to use your own color like this:
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
I know how to set the theme for an Application and/or Activity in Android, but I'm wondering if it's possible to change it for an Activity using the Graphical Layout editor in Eclipse 4.2, ADT 20.0.1. No matter what I change the drop-down to, the AppTheme style from styles.xml is always used when I run the app, despite the display preview changing based on what I select. Is it currently not possible because the theme gets set in the AndroidManifest?
styles.xml:
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
The drop down box in the GUI is used to see what it looks like, if you want the theme changed then you have to edit the Android Manifest yourself
If you want to edit the theme using a drop down, in one of the tabs in the Android Manifest, I think its "Application" there is an option to change the theme and it has a list of themes.
Yep, the theme must be set in the Manifest or in Java.
The drop-down on the layout editor is only there to help debug and test theme issues and whatnot, it doesn't have any effect on your actual app.