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.
Related
In my android studio, there is no style.xml file.
There is a themes folder having two themes.xml files.
Please tell which themes.xml file should we use for android tab functionality.
It got changed in Android studio 4.1
Actually, in the older versions of Android studio, if you want to enable dark mode in your app, you have to manually create and define the properties in your dark theme XML file, but now it is automatically generated as mostly all new apps are moving towards dark mode in their applications.
You can still delete these files from your Android studio project if it doesn't fit in your use-case.
There are two themes.xml in the new Android Studio project templates.
One is for a light theme and the other one is for a dark theme.
More info on dark theme
Implementing a dark theme (or black theme) is very easy today thanks to
Theme.DayNight and
AppCompatDelegate
Android comes to us allowing us to declare
night/colors.xml
and
night/styles.xml
Full example here: https://github.com/android/user-interface-samples/tree/master/DarkTheme
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)
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.
I have an application, that need to run in different size devices
For this, I added the next folders: res/values-normal and res/values-large.
Everything works fine except the application style was modified.
For example the Spinner was like the Model1 and after adding the folders it became like the Model2
http://postimg.org/image/cf3qa2oqd/
If I remove these folders, all returns as before (Model1).
Thanks,
NB: I was not able to add the image here.
the solution is:
change the Application Theme in the Style file
<style name="AppBaseTheme" parent="android:Theme.Holo">
it works fine.
I'm using the HoloEverywhere library in my Android app to ensure a consistent theme across all supported devices. However, I'm running into trouble with activities that utilize Holo.Theme.Dialog: on my Android 2.2 emulator it displays correctly, but on my Android 4 device (which has the actual Holo theme available) the layout cuts off items on the right edge of the dialog.
My question is, how can I force devices that have the stock Holo theme to use that instead of HoleEverywhere? Or, how can I modify HoloEverywhere to make activities styled as dialogs display correctly on Android 4+ devices?
Screenshots:
Dialog in Android 4+
Dialog in Android 2.2
I'm not sure if this bug has been fixed in HoloEverywhere or not, but my solution was to change all of my dialog activity classes to AlertDialogs. This required some code changes, but now I can be sure my dialogs will look and act as expected.
Here's what you need to do:
In your values folder, create a style in styles.xml file referencing Holo.Theme as a parent. In my case, I used AppBaseTheme
<style name="AppBaseTheme" parent="Holo.Theme.Light"></style>
In your manifest, make sure that you are referencing this style in your activities and in your application tag.
<application
...
android:theme="#style/AppBaseTheme" >
Create a folder in your res folder named values-11 (if there isn't one already)
Create another styles.xml file.
Copy the same style you placed earlier in values folder, but reference the built in Holo theme included in 4.0
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"></style>