Android Different Screen Sizes - android

I'm working in Android Studio, this app is aiming to target devices from API 10, several features I am using for supporting old and new devices I am getting from appcompat library.
When I test in my phone, the app design seems Ok, but I know I have to mantain compatibility for other devices, like tablets. Untill now, I only have created folders in drawable, for different screen densities (mdpi, ldpi, xhdpi...).
The point is how can I support different sizes (i.e. one layout for small phones, other for tablets...). I heard about create folders in layout like small, medium and large, but in Google developers site, this is not recommended, I should use intead sw...dp, however it seems is supported only for api 13 and above.
I am considering make an app for phones and other for tablets, unless there is something I can do, keeping support for api 10 and above and supporting different screen sizes.

As you said, in the android documentation you can find (http://developer.android.com/intl/es/guide/practices/screens_support.html):
A set of four generalized sizes: small, normal, large, and xlarge
Note: Beginning with Android 3.2 (API level 13), these size groups are
deprecated in favor of a new technique for managing screen sizes based
on the available screen width. If you're developing for Android 3.2
and greater, see Declaring Tablet Layouts for Android 3.2 for more
information.
It tells you to not use them just if you are designing for API 13 and above. If you don't then you should use the deprecated identifiers.
I don't think make an app for an API lower than 15 has much sense, here you can see some charts of API distribution:
http://developer.android.com/intl/es/about/dashboards/index.html
With API 15 you are covering the 96.4% of the users.

Related

android best practice for supporting multiple screens

GIVEN:
Starting with API Level 13 (Android 3.2), the screen sizes (small,normal,large,xlarge) are deprecated in favor of using the swdp qualifier. It is strongly recommended that applications that are meant to run on Android 3.2 or higher should be using these newer qualifiers. http://developer.android.com/guide/practices/screens_support.html
THEN:
What is the best practice for maintaining compatability with api 7+ without making the problem even more complicated by using BOTH techniques at the same time?
To clarify: When creating resource folders for alternate layouts, dimensions,values, etc, with the requirement of supporting api 7+, should we use the deprecated qualifiers (small, normal, large, xlarge) or the new qualifiers (sw600dp, sw800dp etc) or both at the same time?
update:
I just found a similar question where the accepted answer suggested using ONLY the older Abstract Size Bin qualifiers:
https://stackoverflow.com/a/15113877
Use layout aliases.
Quotation from the official documentation:
"The smallest-width qualifier is available only on Android 3.2 and above. Therefore, you should also still use the abstract size bins (small, normal, large and xlarge) to be compatible with earlier versions."
Here is the link for more information - Use Layout Aliases

How to use screen size qualifiers when targeting multiple Android SDKs?

I'm developing an app whose target SDK is version 8. Despite that, it must work in newer SDKs (Android 4.x, for example).
This site says:
The configuration qualifiers you can use to provide size-specific
resources are small, normal, large, and xlarge. For example, layouts
for an extra large screen should go in layout-xlarge/.
Beginning with Android 3.2 (API level 13), the above size groups are
deprecated and you should instead use the swdp configuration
qualifier to define the smallest available width required by your
layout resources. For example, if your multi-pane tablet layout
requires at least 600dp of screen width, you should place it in
layout-sw600dp/. Using the new techniques for declaring layout
resources is discussed further in the section about Declaring Tablet
Layouts for Android 3.2.
What is the best practice in my case? I do know how to handle SDK differences/deprecation when it is about code (verify in runtime what OS version is running). But I don't know how to handle resources in this case.
Should I keep the old standard and use layout-{small,normal,large,xlarge} even with build target >= 13?
Should I change both targetSdkVersion and the project build target to something equal or greater than 13, keep minSdkVersion equals to 8 and use layout-sw<N>dp?
Here is an interesting answer:
Android resource size qualifier
which leads to http://developer.android.com/guide/topics/resources/providing-resources.html
where there is stated that layout-swdp was added on Android API level 13 (Android 3.2) so it's up to you whether you support lower versions, in this case you'll keep using layout-{small,normal,large,xlarge}.
So my answer is, go to the new standard in your case.
Here are general statistics to help you target your minimum version but you may look for more precise stats (limited to a country etc): http://developer.android.com/about/dashboards/index.html

Why does an Android 2.3.3 7 inch tablet use xlarge resources?

My app has different layouts and styles for xlarge screens. This is important because on phones it is only used in portrait and on tablets it is only used in landscape.
A user contacted me a few days ago because since I published the update with the tablets layouts he can't see some of the objects in my main activity (prior to this update I only had portrait layouts - also on tablets). He uses a 7 inch tablet running Android 2.3.3 and for some odd reason it is using the layouts and styles from the xlarge directories even thew it should use the default layouts and styles.
I tested it on the emulator and had the same problem. I then changed only the android version to 3.1 (did not change width, height and density) and it worked as expected - the default layouts were used.
I don't want to use version qualifiers (layout-xlarge-v13) because then users with old android versions that have an xlarge screen will get the wrong layouts. For android 3.2 and up I could use sw720dp but older versions will not use this so problem remains.
I am able to tell at run time that the device is not large enough for the xlarge layouts but what can I do in that situation? Is there a way to make it use the default resources?
Android doesn't give its blessing to any 7-inch tablets running Gingerbread or below since Honeycomb was released. This means your device must be either old, or non-CTS compliant. You are looking at an extremely small pool of devices that are: API level 7-10 (roughly), 7-10 inches in size, that live outside the main Android ecosystem.
If you want to support such devices, I would recommend that you make layout-large-v7 and layout-large-v11. Assume that these nonstandard tablets will select the first one, and design for low- or medium-density 1024x600-pixel displays.

Why layout-large-v11 resource does not apply on Android 4.0 WVGA800 phone

I am testing with Google's iosched2011 app, and tested with a 4.0.3 simulator.
I am wondering why layout-large-v11 resource does not apply on Android 4.0 WVGA800 phone. It looks like 800*480 is taken as a large screen, and android 4.0's API level is big than 11. So it should apply the resource on that folder in this phone, but it turns out not.
Check in your app how Android sets configuration:
in activity onCreate add this:
Configuration cfg = getApplication().getResources().getConfiguration();
int sz = cfg.screenLayout&cfg.SCREENLAYOUT_SIZE_MASK;
System.out.println("size: "+sz);
in logcat you'll see number, one of these.
On Samsung Galaxy Nexus with 4,65' screen I get 2 = SCREENLAYOUT_SIZE_NORMAL. So you can expect same.
From Docs:
A set of four generalized sizes: small, normal, large, and xlarge
Note: Beginning with Android 3.2 (API level 13), these size groups are
deprecated in favor of a new technique for managing screen sizes based
on the available screen width. If you're developing for Android 3.2
and greater, see Declaring Tablet Layouts for Android 3.2 for more
information.
What mice said. Your screen size category should always be primarily a function of its physical dimension, not the pixel count.
Furthermore, and logically, all screens of the same size class should be round about the same size in dp (density-independent pixels).
For more details, see: http://developer.android.com/guide/practices/screens_support.html#range
So no, your phone should not be LARGE, no matter how many pixels it has. If it's big enough to be large, then you'll look quite silly holding it up to your head.

Switching to Android 1.6 shrinks url images

So basically I had to switch from 1.5 to 1.6 to add in Mobfox. As soon as I did this all the images being called by url are now being displayed much smaller. Is there a way to counter act this because it is kind of annoying and they were just the right size before.
I suspect you'll have to rework your images due to the different way that Android v1.6 onwards handles differing screen sizes and resolutions.
From Strategies for Android 1.5
All applications written for Android 1.5 or earlier, by default, support only the baseline HVGA screen used on the T-Mobile G1 and similar devices, which is normal screen size and medium density (mdpi). Android 1.6 introduced support for different screen configurations and added APIs that allow applications to control how they operate on different screens, using alternative resources for different screen configurations.
See this article for supporting different screens for v1.6 onwards...Supporting Multiple Screens

Categories

Resources