Program different layouts for different versions in android - android

I have to program my Android app with the best compatibility to different screen sizes (tablets and smartphones) and to the versions 2.3, 3.2 and 4.0.
I know about the possibliy to name the folders of the layout like res/layout-sw600dp/. to match the layout exactly to different screen sizes.
So, cause I will use completely different layouts for Tablets / Smartphones, I would start with a "Load Screen", which tests which Android-version is used and if there is used a tablet-or smartphone-device, cause for example in the layout for the Tablet, there will be Buttons on some screens that won't be there on the smartphone.
So I will have to separate all this in packages, like this:
Common
2.3
Tablet
Smartphone
3.2
Tablet
Smartphone
4.0
Tablet
Smartphone
I would choose this separation, cause it's the best way, in my opinion, to be prepared for upcoming *updates*, if, let's say there should be added a Button in the ToolBar in Android 4.0.
Is this separation a good thing in your opinion or is this a complete overload?
Are there any other new features in 4.0 that I should be aware of?

You can also name your resource folders to indicate version number (like /res/layout-v11) or (/res/values-v13)
Regarding your question about separation - it really depends on your particular requirement. A common approach to this problem is a fall-back mechanism: You provide a few specific layouts (for example, an xlarge landscape v11 layout), and a few generic ones to fall back to.
Of course, this is an "idealistic" solution; and it doesn't always work that way. In other words, it is mighty difficult to practically implement an app that is compatible with so many versions of Android solely by providing alternative resources. Even if you use the compatibility libraries (which helps a bit in reducing version-specific code); you will still have to adapt your code based on the version at run-time.

You can find out the Android version looking at Build.VERSION.
The documentation recommends you check Build.VERSION.SDK_INT against the values in Build.VERSION_CODES.
And based on that version you can set your layouts in if else conditions

Related

PercentRelativeLayout for same screen on Android phone and Tablet?

The screens in my app needs to be displayed in the same way on both type of devices, phones and tablets. Currently my app works fine on phones, but they behave weird when run on tablets. The problem occurs with the positioning and size of components in the screen.I have 9 patch images generated for all the images being used but still for some components that I use absolute size/margin values such as 30dp,50dp etc do not seem to be good measures that work well on a tablet. Some of my thoughts/questions are:
PercentRelativeLayout - is it the best solution to overcome this
problem?
Is there a way that layouts can be defined so as to draw
differently on phones and tablets. Please note that that I do not
have any complex menus or behaviour that needs to work differently
on different devices, they are same.
Do I have to develop 2 different apps?
you have to make different layouts for both android phone and tablet.
Look at this link
Read more on the Android developer documentation after reading answers above. Found this resource to be more explicit for someone who is totally unaware of supporting multiple screens. http://www.survivingwithandroid.com/2012/07/how-to-support-multiple-screen-in.html

different appearance on different phones for Android

We are getting ready to release an app, there is a slight difference in appearance on my development phones a Moto X and Galaxy Nexus, and my clients phones. He has a HTC One S with Android 4.4.4. Are there any websites or tools that I can test the appearance on for different phones? He lives in Brazil and me in Florida, so using his is out.
You should use the Android Virtual Device for this. You can use whatever version of android you would like, there are tons of predefined device sizes/resolutions or if none of those suit your needs you could always define your own.
Are you using Eclipse/ADT as your IDE? If so, the layout editor provides different views for a handful of different devices.
I am having trouble attaching a screen shot, so I will just explain. In the layout editor, you will see drop-down selectors for (a) Device/Screen Type, (b) Orientation, (c) Application Theme, (d) Android API level. This provide reasonable previews of you layouts.

Is it ok to target Android 1.5 for my business app?

I am writing a simple business app that retrieves data from a server for very light content. IS there any disadvantage to building this on Android v1.5?
I'd like to make my application available to as many Android devices as possible. I was just wondering if there are any significant performance disadvantages if I build for this target platform and run it to v2.2 or v2.3.
It all depends on what APIs you are using. You may need to make some compromises that might affect performance if you stick to the 1.5 API. Otherwise, as far as performance goes, I think the main thing you'll need to be concerned about is compatibility mode with large-screen devices running newer OS versions.
According to the Android statistics, V1.5 devices represent less than 1% of the market. The market for your app may have different statistics, of course, but I wonder how important 1.5 is to anyone.
A better approach is to design the app, determine what APIs it uses, and then decide whether backward compatibility is worth whatever compromises in app performance or features that would entail.
I would think the major disadvantage would be the lack of different screen resolutions. I believe that was a 1.6 and up thing.
There's nothing "wrong" with 1.5, but I'd say you're WAY beyond the point of diminishing returns. If a client asked us to support 1.5 I'd consider not taking the job ;) 1.6 is the only practical minimum at this point (IMHO, which I sure many will disagree with).
Short answer: no, don't target 1.5.
Long answer: 1.5 is hardly run by anybody nowadays (see http://developer.android.com/resources/dashboard/platform-versions.html ) and you'll encounter issues when you want to add in some cool neat features that aren't in 1.5 but are in other versions (1.6+). One big issue here is 1.5 does not support multiple screen sizes. This feature was introduced in 1.6 (using the folders drawable-hdpi drawable-mdpi etc) and as a result, when you specify in your manifest minSdkVersion="3" your application will automatically be run in Screen Compatibility mode (see http://developer.android.com/guide/practices/screen-compat-mode.html ). You can work around this by setting min=3 and target=4, but it will become tedious since there are many other really useful functions you simply won't be able to use in 1.5. Realistically, 1.6 should be the baseline.
You can target 1.5 but you will loss some new features in new Android versions, Also must take in consideration memory management for old android devices.
2.1 and above enough to cover almost the market. check this

What's the difference between layout-large-v11 and layout-xlarge

I'm working on a Tablet application.
What's the difference between this two res folders: layout-large-v11 and layout-xlarge?
The first option is from the IOSched app.
Are both valid for tablets? Which one is better for design tablets layouts?
Many thanks for the help.
v11 is there to help distinguish between large devices that are still running older versions of android. This distinguishing is necessary because there were some big changes at Android 3.0 (version 11 of the api), in terms of style. So the v11 allows you to say "Ok, if this is a newer version of android, use this newer style of layout, other wise use this older style".
Bottom line, you only need to use it if you want to provide two different layouts: one for versions of android that are pre-3.0, and one for versions that are post-3.0. v11 actually has nothing to do with the size of the screen itself, merely what version of android you're running on.

Android phone and Tablet problem

I know this is not a technical related question.But i do not have any idea.I am going to develop a project which should be supported in both phone and tablet.Is it possible having one project working for both tablet and phone ?
Yes. The only thing you need to keep in mind where you keep your graphics. Because it will cause different problems if you do not treat and handle them depending on the screen size. Only thing matters is the android version. If you deploy your app in any phone or a tablet where the version is newer or equal to the target version it works. But of course you cant take a call or some other mobile functionality from a tablet if its not supporting that features.
You can use drawable-hdpi,drawable-mdpi and drawable-ldpi for the graphics(images which use in project) and also use layout with multiple screen by custom layout like layout-480x320 , layout-600x1024 etc. in layout you can custom screen xml file.

Categories

Resources