How set ICS theme for application with minSDK 7? - android

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?

Related

error in styles in API8 in Eclipse

could anyone please help me with this?
I opened an existing project and I get this error in the screenshot.
The problem is that you are using a style which require API 21. You are referencing a style called Widget.Material.ActionButton. So you need to put this reference in a v21 directory to use the CompatLibrary which I would recommend.
The real cause seems to be that you have a very low target SDK (like you wrote in the comments API 8). You should set it to the most newest one, it cannot break anything. So set the target SDK to API 21 or newer and it should work fine.

Android layout dont change after choosing higher SDK for Actionbar

I have made a programm based on SDK 7. Now I want to add an Actionbar to it. I changed the minSDK to 11 in the Manifest. Isn't that supposed to change the design of the layouts I already have?
Problem is, that I get returned "null" by getActionbar(). I read, that I have to activate the title bar in the OnCreate of the mainactivity. But that does'nt change anything, still "null".
I can see the titlebar, but on SDK 7 it's smaller than on SDK 11. Can't really describe my problem. I just want to use Actionbar on my old written App. But the Layout still looks like in the pic below (left).!
LayoutProblems
Hope someone can help me.
Thanks!
You should also replace the old android.jar with the new one from SDK 11 to get the new GUI. If you are using eclipse for development, just check different Project buid target under Project - Properties - Android.
If you want to use ActionBar in older devices you must use actionbar support library which is provided with the sdk.

Give Android 2.3.3 Look And Feel to Android 4.0

When I run my application on Android 2.3.3 then it show different look and feel to android 4.0. When I run my application in Android 4.0, I want it to have the same look and feel as Android 2.3.3.
There are already a lot of questions asked on this topic but all the questions are "How to give higher version look and feel to lower version". But in my case I want to give lower version Look And Feel to higher version.
There is one solution which is, if I compile my application with Android 2.3.3 and run on Android 4.0 then it give Android 2.3.3 Look And Feel. But here I am not able to add features from Android 4.0, so this option is not a right way to achieve my goal.
So what I need to do?
Here I am attaching Look And Feel which I want:
But instead of above Look And Feel it show following look And Feel on Android 4.0
Set your Application's theme to #android:style/Theme in your app's manifest.
For example:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme" >
This will set your Application's Theme to the former default Android theme, which has been replaced by Holo in newer versions of Android.
You can also select the DeviceDefault theme in a similar manner.
Make sure your targetSdkVersion is set to a value of 10 or lower, and that your application does not declare a theme based on Holo when running on newer versions. This will keep the Holo theme elements from being applied on newer devices.

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.

How to make my app use 4.x style while customer's android phone is 4.x?

How to make my app use 4.x style while customer's android phone is 4.x?
I know set android:minSdkVersion="15", the style will be 4.x. But I want the app should be compatible for android 2.0 or above.
Thanks,
You can Set your theme as Theme.DeviceDefault or define your theme styles.xml under values-11 and values folders.
Be carefull that use lint to check if you use the NewAPI with version check.

Categories

Resources