My Xml design does not work on all Android devices?

In my project, My Design works fine on my Android 2.3.4 Android phone. But in 4.0.1, my screen does not display completely (some designs are cut from Bottom). Why?

+3
android design xml compatibility
Oct 05
source share
3 answers

Since you have not posted any code, I will just give you a brief overview of Android layouts and resources.

You need to create several resources for your application. Android has 4 resolutions (ldpi, mdpi, hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and very large). Thus, you need to make 4 layouts (or 3 if you do not plan to support tablets, since tablets fall into the super-large category) to support screen sizes.

Here is a general guide:

Place the layouts for small, medium, large and extra large in the res / folder as follows:

res/layout/sample_layout.xml // default layout res/layout-small/sample_layout.xml // layout for small screen size res/layout-large/sample_layout.xml // layout for large screen size res/layout-xlarge/sample_layout.xml // layout for extra large screen size 

you can also use

res/layout-land/sample_layout.xml for landscape orientation for all screen sizes or you can adjust the landscape orientation for specific screen sizes as res/layout-medium-land/sample_layout.xml

note that all layouts have the same name.

After you have the finished layouts, you also need to take care of the image resolutions.

again in the res / folder add the following images:

 res/drawable-ldpi/sample_image.png // low density res/drawable-mdpi/sample_image.png // medium density res/drawable-hdpi/sample_image.png // high density res/drawable-xhdpi/sample_image.png // extra high density 

All images have the same name.

general guidelines for image design:

 ldpi is 0.75x dimensions of mdpi hdpi is 1.5x dimensions of mdpi xhdpi is 2x dimensinons of mdpi 

Typically, I draw mdpi images for a 320x480 screen, and then multiply the sizes according to the rules above to get images for other resolutions.

Android will automatically choose the best combination of layout and image depending on the device. For example, for a medium-sized device with a high resolution, an image with a mask and medium density will be displayed to the user.

Make sure you create emulators for all of these combinations and thoroughly test the application. here are the white papers for more information:

https://developer.android.com/guide/practices/screens_support.html

+21
Oct 05
source share

here I am sending you a document for device screens and densities, this will help you understand which device will receive the image from which folder ...! android screen sizes and densities

+4
Jul 04 '13 at 7:06 on
source share

One layout does not always work for all different screen sizes. Since Android has at least 4 different screen sizes (small, medium, large, very large), you will need to use dp (density pixels) in a smart way or have a different layout for each screen resolution (which I personally recommend)

As you do this, create a folder for each type of layout you want, as shown below. A quote from http://developer.android.com/guide/practices/screens_support.html : For example, the following list of resource directories in an application that provides different layout schemes for different screen sizes and different bitmap images for medium, tall, and especially screens high level.

res / layout / my_layout.xml // layout for the normal screen size ("default")

res / layout-small / my_layout.xml // layout for a small screen size

res / layout-large / my_layout.xml // layout for a large screen size

res / layout-xlarge / my_layout.xml // layout for an especially large screen size

res / layout-xlarge-land / my_layout.xml // layout for a particularly large orientation in landscape orientation

you can also just use

 <supports-screens android:smallScreens="false" 

in your manifest to select which screen sizes are available to you. But then people will not be able to download it from the store at all, if they have a screen of different sizes.

+1
Oct 05
source share



All Articles