I wonder what would happen if i write some code in the file style.xml in the folder values-v14 and when this is executed in a device than not use this api 14, would happen in that case ?
I am new in this language of android..
Thank for your time...
It's worth indicating that i.e. values-v14 will be used for
API 14 and higher, unless there's another folder that got higher
version i.e. on API 14 and higher, content of values-v14 will be
used.
it will not be selected at all for versions below API 14
For more info you may see at
Styles and themes on values, values-v11 and values-v14 folders
Related
I'd like to customize one drawable e.g.
/drawable/image.png
only for APis 19 to 21. For later APIs (after 22 incl. I'd like a drawable to be different). Do I need to create directories
drawable-v19,
drawable-v20,
drawable-v21,
drawable-v22 (for the others?)
? It's a bit unclear to me how it works...
You should only need to create directories for the versions that set a different resource. So your resources directory would look something like:
res/
drawable/ --> SDK version below 19
image.png
drawable-v19/ --> SDK version between 19 and 21 (including both)
image.png
drawable-v22/ --> SDK version 22 and greater
image.png
Edit: Seems to be working this way. I've set up a small project with strings.xml for sdk 19 and 22, launched two emulators, with sdk 21 and 25. The SDK 21 one showed the string in the v19 strings, and the SDK 25 the one in v22 strings. Here's a pic with the results:
Hope it helps. (Couldn't test it with sdk lower than 19, but that should take values from the default file, since no qualifier applies.)
You can create drawable folders like drawable-v19, drawable-v20, drawable-v21, drawable-v22 for each custom images for each versions. If the app is running on one of these devices it picks from these matching version custom respective folders or else falls back to the generic drawable folder.
What is the main difference between these two files : styles.xml (res\values\styles.xml) and styles.xml (res\values-v21\styles.xml ?
For targeting old android versions, which file should we modify?
Android will use res\values-v21\styles.xml if the user's device is running Android API level 21+ (Android 5.0+) & will use res\values\styles.xml for older versions
It just means that the styles differ in android versions.
styles.xml in values-v21 mean that, that particular style is for Android API 21 version 5.0+
while styles.xml will be for any other Android version besides 5.0+.
its the same as language where you create an activity for en, fr, pk etc.
Older version would automatically be targetted by the values/styles.xml file.
Hi I am having an old app created on version 2.2.3.
I am modifying the app for 4.0 and above version handsets.
can someone tell me if I can use selective theme
like for 2.2 devices dark black theme
For 3.0 and above the holo
Can i use version specific themes?
Create a different values folder with following name:
values-v17
and put a copy of style.xml init
in this style.xml you can overrite styles set in default values folder and for the devices with API-17 this style will be applied
If you have a folder for values-v11 all the devices with API level 11 and more will refer to files from this folder.
I have a question about minSDK. I took a project example in here: Contacts Providers.
This project has a minSDK = 5. And in styles.xml some attribute which require higher sdk version like:
android:textAllCaps --> min 14
android:fontFamily --> min 16
But that project so no any error and run fine.
When I copy some style into my styles.xml in my project. It causes an error:
android:textAllCaps requires API level 14 (current min is 11)
...
Can someone help me with the compile error?
You can use those styles in the respective minSDK version by using resource qualifiers. In your resource directory: there is base styles, add folders to res/styles-v14 (for use in ice-cream sandwich and greater, where minSDK is 14) and styles-v16 (so on so forth if you need the styles to be applied when available)
Now when the style needs a higher SDK version, place it in respective style resource directory. textAllCaps goes into styles-v14, android:fontFamily goes into styles-v16.
More can be found here on resource qualifiers ;)
http://developer.android.com/guide/topics/resources/providing-resources.html
Hope this helps buddy, happy coding!
EDIT: previously misunderstood the question/scenario. Sorry!
I think the problem is your Target API level. Make sure that the target api level is at least the level in which the APIs were introduced. In this case, 14.
If you build from command line you would just do
android update project -p -t
(I think what the command does is just update project.properties and sets target=android-14)
My Android project was working fine when I noticed that I had checked SDK version 4.2 when I meant to target Google 2.33. I set the project back to G2.33 (In the manifest it minsdk = 8 targetsdk=11) and now I have errors on two different styles.xml files in two folders named Values-v11 and values-v14.
the styles.xml in the Values-v14 folder has an error on the following line...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
the st yles.xml in the Values-v11 folder has an error on ...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
My other projects, that all target 2.33 don't even have these folders. What is the best way of me getting out of this mess?
Thanks, Gary
You could simply delete these folders if you don't want anything specific for SDK level 11, and the one for 14 won't be used anyway if your targetsdk is 11.
If you want to retain the one for api level 11 for custom behaviour in API level 11, you need to set the project to compile with API level 11 - i.e. if in Eclipse, select the project, go to Properties, select Android and then set the project build target to "Android 3.0" or "Google APIs" for API level 11 if you need the Google APIs.