I don't understand what I've to do in my project when I've downloaded my .zip in the awesome tool http://jgilfelt.github.io/android-actionbarstylegenerator/
I've all resources, but I think I have to do some modifications in my styles.xml & themes.xml in addition to put theses resources in my project ?
My resource suffix is *_test
Thanks a lot for your answers :)
but I think I have to do some modifications in my styles.xml & themes.xml in addition to put theses resources in my project ?
That depends on what you have done so far, prior to using the generator.
The generator should have given you styles_test.xml files, probably in res/values/ and res/values-v14/. These will define a theme, Theme.Test.
If presently your theme for your application (or individual activities) in the manifest is a standard ActionBarSherlock theme (e.g., Theme.Sherlock), just change it to reference your newly-generated Theme.Test, and you should be good to go.
If, on the other hand, you have already been working on a custom theme for other things, then you will need to decide for yourself how best to blend in what is found in Theme.Test into your own custom theme. For example, you might have your custom theme set Theme.Test as the parent theme.
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
(1) I am confused with the themes in android.
For example android:Theme.Material.Light and Theme.AppCompat.Light.
Also Holo light and dark themes.
I don't understand when to use what. Can someone explain me the differences of these android themes?
Need a good explanation about these themes so that I can understand how this works in my style.xml.
(2) why there are prefixed and non prefixed attributes in style tags.
<item name="colorPrimary">#3F51B5</item>
<item name="android:colorPrimary">#3F51B5</item>
when to use prefix?
Can someone explain this?
The important thing to note about these themes is that not every version of Android will support them. Thus, you may want to use different themes depending on which version of Android your application gets installed on. Derek Banas had a great video on styles and themes:
https://www.youtube.com/watch?v=W3xHIN15hP8
I'm not the most knowledgeable about styles, but I'll give it a shot. I believe that "android:colorPrimary" is used when you are overriding an attribute in an already defined style. I'm not the most knowledgeable about styles so I will lead you to the documentation page that I found that seems to cover this topic fairly well:
http://developer.android.com/guide/topics/ui/themes.html
Here are some references for further reading
https://plus.google.com/+AndroidDevelopers/posts/JXHKyhsWHAH
https://plus.google.com/+AndroidDevelopers/posts/AV2ooBWY1iy
I used google but didn't find an accurate solution, for changing themes programmatically.
I want to change everything programmatically: styles, colors, attributes etc., without using style.xml, theme.xml or any other xml file.
I have searched, but styles are defined in an xml file like that Using Themes in Android Applications
I know this is an old question, but if someone's still looking for a solution, checkout the GreenMatter library for the Material theme, or for the Holo theme holoaccent.
To style my android application an make it more beautiful, i have used the action bar style generator to create a theme and Action holo color generator
They both give me a res folder when i extract and i want to use both of them in my application, but am not sure if thats allowed or would create some conflicts.
I would like to know how i can include both of them in my app.
Thanks
There is a pretty good write up on how to do this - have a look at this:
http://www.androiduipatterns.com/2012/09/creating-custom-android-styles-easy-way.html
As the link in Wayne May's answer suggests, you just have to make the ActionBar theme extends the Holo color's theme.
Here are the steps needed to get this to work:
Chose a prefix for your themes (the last part of your app's package name for example)
Generate and download a theme for you action bar using ActionBarStyleGenerator. Name this theme <prefix>_ActionBar.
Generate and download a theme for your widgets using Android Holo Colors Generator. Name this theme <prefix>_Widgets.
Unzip the files you downloaded in your resource folder (be careful not to overwrite anything).
Edit the files values/<prefix>_actionbar_styles.xml and values-v14/<prefix>_actionbar_styles.xml to replace every occurrence of parent="#style/Theme.AppCompat" with parent="#style/<prefix>_Widgets"
Use <prefix>_ActionBar as your theme (or as your theme's parent)
This line style="#android:style/Widget.Holo.Light.Spinner" makes my minSdkVersion go from 1 to 11!
How can I design my views for newer versions but still display ugly views for older versions (but allowing them to get the app) ?
The spinner is not supported on old versions. You can create the specific style that uses the spinner on a folder named values-v11, and on the style default folder (only "values") design a "ugly" spinner. Note that the styles must have the same name on both folders.
Check this answer https://stackoverflow.com/a/15339215/799979
The Spinner was added in API 1. It's the style you are attempting to use that is API 11+.
To solve this, you put another styles.xml file in the values-v11 folder. Then you have the Spinner use a style from your styles.xml file. In the styles.xml file in the default values folder you have your new style inherit from the android style you want to use. In the styles.xml file in values-v11, you modify that same style to use something can be used in older APIs.