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.
Related
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
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.
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.
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
could anybody tell me how can I set a theme for my application which will change when version of Android will change. For example if anybody will use my app on Android 2.1 theme will look like this: http://daily-money.googlecode.com/svn/wiki/img/prefs.png
But if anybody will use my app on for example Android 4.0.3 theme will look like this: http://img.tapatalk.com/dcff019c-27ba-1e1a.jpg
I have used minSDK 7.
Thank you.
What you want is detailed in on this page: http://android-developers.blogspot.com/2012/01/holo-everywhere.html
In the section titled "Defaults for Older Apps"
You setup 2 theme files, one in the values directory and one in the values-v11 directory. Then you reference that theme file in the Manifest. As outlined in the page I linked above. You need ALL THREE blocks of XML outlined on that page under the "Using Holo while supporting Android 2.x" section.
first get the version of android running on the device :
if (android.os.Build.VERSION.SDK_INT >= 11) {
....
en after you can use setTheme(..) before calling setContentView(...)and super.oncreate() and it should work fine
#letroll, what parameter do you pass to setTheme? Does it require increasing min sdk to 13 to make the SDK available?