I'm building an app but I would love to upgrade it to the Android Lollipop design. I use Android Studio to develop my application and I set my minimum SKD to API 21 (Lollipop) and I want it to run on Kitkat and Lollipop, so now I got the Lollipop interface and want to run it on Kitkat but ofcourse this isn't possible because the minimum is Lollipop. And as I expected it didn't ran on Kitkat. So I changed the minimum SKD to 19 in build.gradle and the target SKD I let as it was (SKD 21) so now Kitkat could run the app but the full layout is Kitkat style , not Lollipop. Even tho I made the app as Lollipop design and Android Studio previewed it as Lollipop interface. I hope somebody could help me get the Lollipop interface on Kitkat.
Thanks in advance.
It is not strictly possible to get "the Lollipop interface on Kitkat". You are welcome to use the appcompat-v7 backport, which will give you:
an action bar styled according to Material Design and therefore reminiscent, though not identical, to the native Android 5.0+ action bar
tints applied to certain widgets
a Switch backport that looks like the Android 5.0 version of Switch
a Toolbar backport
You can implement Material Design, on Pre Lollipop devices by using android support library appcompat_v7 rev21and then setting the theme in AndroidManifest.xml as #android:style/Theme.Material (dark version) OR #android:style/Theme.Material.Light (light version) OR #android:style/Theme.Material.Light.DarkActionBar
Below are the official links for doing the same :
https://developer.android.com/training/material/theme.html
https://developer.android.com/tools/support-library/features.html#v7
Hope this Helps!
I have been asked to look at getting an existing app working on an Android phone running Andrdoid 2.3.6 ( API 10? ).
The app currently used the ICS ActionBar, is there any way of doing this with API 10?
I dont think even ActionBar Sherlock goes down to that API level.
I dont think even ActionBar Sherlock goes down to that API level.
No, ABS supports everything from Android 2.0 (API 5) upwards.
ActionSherlockBar, supports almost all version.
I actually used it extensively on 2.x devices!
I am new in android development. And I have confusion about android layout compatibility.
I am creating one app in android 4.0.3 but it's UI look like android 2.2 related UI.
I used all default controls in app but it not look like 4.0.3 related UI.
So any one can help me in below problems.
If I am creating app in android 4.0.3 then how it's look in android 2.2 and vice versa?
How can I create app which is run in all android version with standard UI?
Please help me.
Thanks in advance.
Your app will use the system theme that you specify, or the custom styles that you specify. If you do not create custom themes or styles your app will use the default styles on each platform. So on 4.0.3 it will use the ICS theme, and on 2.2 it will use the older theme.
To create an app that will run on all versions, you should probably set your target API to 1.5, but there are few devices with 1.5 left, so you'll probably set your API target to 2.2, and this will make your application run on all the devices with Android 2.2+.
I quote from the SDK docs:
"Beginning with Android 3.0 (API level 11), Android-powered devices are no longer required to provide a dedicated Menu button. With this change, Android apps should migrate away from a dependence on the traditional 6-item menu panel and instead provide an action bar to present common user actions."
Further more:
"If you're developing for Android 2.3 or lower, users can reveal the options menu panel by pressing the Menu button.
On Android 3.0 and higher, items from the options menu are presented by the action bar as a combination of on-screen action items and overflow options. Beginning with Android 3.0, the Menu button is deprecated (some devices don't have one), so you should migrate toward using the action bar to provide access to actions and other options."
So, if I understand correctly, on devices with Android 3.0 or higher, which do have a Menu button, the depraceted code will still work, while on device with Android 3.0 or higher and no Menu button, the depraceted code will not work.
5 questions arise:
Can these compatibility issues be handled through the Android compatibility library?
If yes, how?
If no, does anyone have a list of devices with Android 3 and higher and no Menu button?
How high is the market share of these devices currently?
Specifying a max SDK, will exclude all devices, no matter if they have a Menu butto or not. Is there are better way, to ensure an app is only installed on compatible devices?
Can these compatibility issues be handled through the Android
compatibility library? If yes, how?
Set your target API to 11 or higher (It's recommended you set it to the latest available version: So, set your target API to 15). Then enable an ActionBar in your application. What used to show up via a menu key now shows up in the overflow menu of the ActionBar, or shows up as individual actions on the bar itself if you set each one's "showIfRoom" true.
If no, does anyone have a list of devices with Android 3 and higher
and no Menu button?
Trying to code special cases is the wrong approach. On devices with a menu button, it'll work with the menu button. On those without a menu button, there will be the overflow menu. There's a blog post about this on the Android Developer Blog.
How high is the market share of these devices currently?
Small but growing.
Specifying a max SDK, will exclude all devices, no matter if they have a Menu butto or not. Is there are better way, to ensure an app is only installed on compatible devices?
Yes: The method I described will handle both scenarios, and it'll work across all devices :) No reason to use maxSdk.
EDIT: To address questions from the comments:
So, if my target is 8, the devices with 11 will not handle the Menu button properly?
If you set your target to less than 11, devices without a menu key will have a "legacy" menu button next to the other soft buttons, like here: http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html
On the other hand, if I set target to 11, eclipse will not warn me, if I use features > 8?
If you set your target to 11 and min to 8, Eclipse won't warn you if you use 9+ features- You'll need to test your app for that. Easy way to do that: Move your target SDK temporarily back to 8, see where the compiler yells at you, make sure those code paths never get hit on devices that can't handle them.
What consequences does it have for distribution on Google Play Market?
Only good ones. If you set a Max SDK, your application would be compatible with fewer and fewer devices as time went on. Having a min version of 8 (instead of scrapping backward compatibility alltogether) means your application is installable on Froyo and Gingerbread devices, instead of only Honeycomb and up.
Can these compatibility issues be handled through the Android compatibility library?
No.
If no, does anyone have a list of devices with Android 3 and higher and no Menu button?
Pretty much all of them. Devices that were running Android 2.x and are being upgraded to Android 4.x will have a dedicated MENU button (e.g., Nexus S). Devices being build new for Android 3.0+ will rarely have a dedicated MENU button.
How high is the market share of these devices currently?
Android 3.0+ represents 8.2% of the devices accessing the Google Play Store as of early May. Most of them will be devices that lack a MENU button.
Is there are better way, to ensure an app is only installed on compatible devices?
The only reason for a compatibility issue is if you relied upon a MENU button for doing things other than displaying the options menu. Simply rewrite that code to no longer rely on a MENU button, and the compatibility issue goes away.
Your deprecated code will work on devices with no menu button. If your target SDK is less than 3.0, devices with no menu button will show a software menu button at the bottom of the screen.
This looks fine on the Galaxy Nexus and other devices with persistent software buttons, but is ugly on devices like the HTC One X, which does not usually have a software button bar.
They have a sample of using actionbar on older devices here. There is also the option of configuring different layouts and activities/methods based on android version, so you can use normal menu on older devices and actionbar in devices that support it. (see here for how to check platform at runtime, and here for using different layout folders based on platform)
We are building an app that is (still) targeted at API Level 8, but we make use of the compatibility package. Because of the specs we cannot target level 14. On a new device (HTC One X) the menu button of the ActionBar is visible below the app. Is there a way to disable or hide that button?
try reading about the ActionBarSherlock, it's a compatibility library for implementing action bar in lower SDK version.
You can try ActionBarCompat. It's pure Android :-)