Values folders for specific android versions - android

I'm just starting to get into material design for android and I ran into small problem - material design guide says to create separate values-v21 folder and create my custom theme there, while all older versions will fall back to default values folder. By the time tutorial was released 21 Android version was the latest, so do I need separate folders for each subsequent android versions (22,23..) now and just copy same theme? Or will all later version will fall back to v21 theme if there's no newer version values folder?

No. Only create a /values/ and a /values-v21/ folder for your styles. This will be used by Android 5 and below and Android 6 and above.
If both folders exist with proper Styles.xml files, then Android 6 devices will use values-v21 and Android 5 and below devices will use values

Related

How can you use different properties in android xml files according to api version?

I am creating a project that uses a big number of icons, in order to support multiple screens easily, I created the icons using vector graphics (SVG paths I believe they are called) which worked ok in my device.
Unfortunately when I tried to use it on older devices (anything with android less than 5.0) I get an inflater exception.
After searching I found out that in order to use vector graphics for those devices instead of using
android:src
I have to use
app:srcCompat
this indeed fixed the problem, but now when I deploy it to a newer device, the icons won't show (at least it doesn't crash though, so that's something)
Is there a way to define some sort of style to use according to api version
so that I can do something along the lines of :
<style name="android.api.21">
<item name="android:src">ic_menu</item>
</style>
<style name="android.api.19">
<item name="app:srcCompat">ic_menu</item>
</style>
Thanks in advance for any help you can provide
Just use the same style name (for example, styles.xml) and in resources folder (app/main/res) create different folders with naming values (common version), values-v21 (for API 21, Lolipop 5.0), values-v19 (API 19, KitKat 4.4) and so on and so forth.

How to force HoloEveryWhere color/assets with Android 4.4

I'm using HoloEveryWhere library with project having min target android:minSdkVersion="8". I converted Holo assets with custom color and I want to get those used with every platform version. However tested with Android 4.4 KitKat device and regular Button and EditText are not behaving the same than with older device. Also ActionBar behaves native way and not using the wanted Drawable I created for background.
With 2.3.x device everything seems to work just fine.
I see values-v11 and values-v14 in HoloEveryWhere values folder, do I need to modify these somehow?
Thanks.
Removing values-v11 folder from HoloEveryWhere values solved most of the issues. Also remember to set KitKat Style to NO if you are using Android Holo Colors to generate the assets.

android - Apply same style to all API levels

I'm new to android and I've got a doubt that I couldn't answer searching.
I'm developping an application that would run from android v2.3 to 4.3. I know that the folders:
- values
- values-v11
- values-v14
containg the style.xml for each API level.
I want to apply the same exactly theme to all API levels. Right now, what I'm doing is copying the content of the xml to the other xml files in the other fodlers. But if I forgot to do that then the app looks different if the device has an android version different from the default one that I use (v2.3)
Is there a way so the app has only one style.xml file for all api levels?
Thanks!
The styles.xml located in the res/values directory is used by all versions, so use this one.

use phone wallpaper as app background - Theme.Wallpaper like behaviour

I wanted to use Theme.Wallpaper in my app. This theme uses the phones current wallpaper as a background. The problem is it doesn't work on a 4.1 device. I also tried recreating the Theme.Wallpaper in my style resources but again it doesn't work for 4.1 devices.
- note that it may not work for lower APIs as well, I only confirmed it working on 2.2.1 and not working on 4.1.
I would like to know why it doesn't work and if there is any solution to that.
I have finally found the answer, it's a bit complex:
In a project built for a target above 14 (mine is 17) eclipse automatically creates a "values-v11" and a "values-v14" folders (applyed for phones or AVDs with api version 14 and above or 11 and above). In those folders are style.xml files that contain the "AppBaseTheme" style, This "AppBaseTheme" style replaces the one in the default "values" folder, which is the parent of (or: is extended by) the "AppTheme" style that is applyed by default to the application..
Now, the way I chose to apply the "Theme.Wallpaper" style to my app, was to have my "AppBaseTheme" inherit from it. Understanding this, it became obvious why my app did not have a "Theme.Wallpaper" like behavior on Systems with API 11 and above: I never made the alternative v11 and v14 "AppBaseTheme" extend the "Theme.Wallpaper" or the more suitable "Theme.Holo.Wallpaper" for v11, and "Theme.DeviceDefault.Wallpaper" for v14.
So, if you have troubles with applying styles, I hope you see this...
EDIT: if your reading this, and have troubles with editing the style.xml file in eclipse, try opening this file in any text editor (my favorite is notepad++) and just delete all the comments than reopen it on eclipse. In case you need comments just add them afterwords on your text editor.

Developoing for android 2.3 and 4.0.3 in a single prject?

Well, lately i've been coding an app using 2.3 emulator, I was mainly testing the app in 2.3.7 phone, but yesterday I updated my phone to android 4.0.3 and the UI looks like shit, in fact, keeps the "bad" looking 2.3 UI.
Now i'm trying to get a nice looking app in both versions of android, the problem is that i don't want to have 2 separate projects an edit both of them, so i want to use one single project and 2 virtual machines for the different versions.
The problem is that if i create a project destinated to 2.3 i can't call to HOLO Theme resources, and if I create a 4.0.3 project it will not even work in android 2.3 right?
so... what do i need to do?
thanks.
You need to set the targetSDKVersion as 15, minSDKVersion as 10.
You need to create various resource folders for these two versions. Example, create a folder 'values-v14' inside 'res' folder and define your widget styles for ICS. Have another folder 'values-v10' and keep your styles for 2.3.3
If required, use the version qualifiers to define separate layout for different versions.
The below links will give you more clear idea.
http://developer.android.com/training/basics/supporting-devices/platforms.html
http://developer.android.com/training/backward-compatible-ui/index.html

Categories

Resources