I have 3 layout folders in my project:
1. layout
2. layout-large
3. layout-small
and as of now i don't have anything in layout-small but layout has layouts with small dimensions and layout-large has layouts with large dimensions.
The problem is:
when i test my app on a 240x320 it uses layouts from layout
when i test my app on a 480x800 even now it uses layouts from layout
Is it because thought i have layout-large, 480x800 doesn't fall into large screens, hence uses the default layout folder?
If that is the case, how can i make layouts for Normal Screens there is nothing like layout-normal or layout-medium.
Moreover, if i design my layout for HVGA (320x480) it should work perfectly for WVGA800 (480x800) since they both fall under same screen size, only density changes. And i am using dp everywhere. Am i right?
any help appreciated.
When it comes to xlarge, large and small then it is depending on size(inches) not on dpi of your device
see below for specification
Additionally DPI is basically for Drawables while SIZE is for Layout.
Just use the following details it may work but i am not sure..
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Just try....
You should check this developer page out it helped me alot. http://developer.android.com/guide/practices/screens_support.html
Even if they have different resolution or screen size that doesnt mean that they have different pixel density. For example a large screen may have less pixel density than a smaller screen.
Another example would be the Samsung Galaxy tab which is 10.1 inch but is still mdpi-large and Nexus One which is less than 5 inch but uses hdpi.
Best of luck
I think I got what is going wrong with you........ lets try this.
suppose you are going to make the application compatible for 480x800 resolution.So for that first of all create two folder for it i.e.
1.layout-sw480dp this is for landscape.
2.layout-sw480dp-port for portrait mode.
Now,put all layout of the resolution of 480X800 in it.you see it will run easily on the particular resolution.
Note:- point here to be noted that for any device resolution let A X B. the name of the layout folder is goes like this.
1.layout-swAdp.
2.layout-swAdp-port.
here "A" is the screen resolution height value of device.
i hope it work for you.
Related
In my application I have a background for activity. This is an image, I am going to use fitXY for it. I am ok if it will be resized a little (keeping aspect ration is not very important) but not very much.
I am going to prepare few images with different size and for both Portrait and Landscape orientation. I am going to cover about 90% of devices.
My question is the following:
What images sizes I need for background?
What folders under "res" I should put these images?
I would like to get very specific file sizes and folder name where to put these files.
The solution should work on tablets as well.
I just used two images with maximum sizes (one portrait and one landscape). Then android resized the to smaller and it looks quite good for me.
I have one background with resolution: 800*1200 px in drawable folder
and another with resolution: 1200*800 px in drawable-land folder
This works pretty fine on tablets.
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
Here's a general guide:
put layouts for small, medium, large and extra large in your 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 target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
note that all the layouts have the same name.
once you have your layouts ready, you need to take care of image resolutions also
once again in your res/ folder add images like this:
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
once again, all the images have the same name.
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
https://developer.android.com/guide/practices/screens_support.html
m/h/xh dpi are the most important. Combine that with the (most common) resolutions and you should be fine for your "90%" target.
i am working on 2.2 version of android and xml is designed according to this version
Specification of emulator : version 2.2, Built-in : HVGA , Memory : 1024
and now i need this application to be transformed into 4.0 version of Samsung galaxy s3 but the screen are very streched and does not look good
thanks in advance if any help.
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
Here's a general guide:
put layouts for small, medium, large and extra large in your 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 target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
note that all the layouts have the same name.
once you have your layouts ready, you need to take care of image resolutions also
once again in your res/ folder add images like this:
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
once again, all the images have the same name.
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
https://developer.android.com/guide/practices/screens_support.html
You have to maintain your xml files in
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Check this Supporting Multiple Screens for how to design your layout for supporting multiple screens
and also for images use
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
I've got a layout-normal and layout-large. Additionally, I provide several splash images with different resolution: 480x800 and 1280x800.
My problems are:
In my task it's said that I must distinguish layouts based on device resolutions(one for 480x800 and the other for 1280x800). Is there any possibility to implement it ? Taking in consideration an assumption that handsets have 480x800 resolutions and tablets - 1280x800 and higher, I could implement this scheme but I'm not sure that it's true.
I've created a test project where I attempted to distinguish layouts based on size, but I can't make android use 480x800 image for layout-normal and 1280x800 image for layout-large: in both cases it shows the 480x800 image. I guess, it's because of size, in case of a device, not equals resolution, in case of an image. However, I need to provide completely different looks for 480x800 and 1280x800. what are my options here ?
Thanks.
PS I'm building against Android 2.3.
You have the "Supporting Multiple screens" documentation that helps on that matter.
For example, the following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
I,m working on android project.
Actually i have develop on small app in honeycomb with resolution(1024*600), when am running the same app in different resolution let say android 2.2(froyo) screen the alignment of images in app screen changes.
Note:Images that are place in xml file are manual arranged(no wrapper thing used for width and height)
Please help me out this question asap..
regards,
Murali...G
Mainly we need to look up is the usage of UI patterns like action bar, Dashboard etc.
But the key point is you should use less static images and as you also use tablet. You should've used Fragments(Of course you would ve done. In case if you have done. Please do it).
Also use 9 patch images or colors for backgrounds. If you are using different images then. You need to keep images for different density.
Maybe all I say is abstract as this question is a abstract one. There is no one line answer for this. As this is a process by itself.
//design your xml in this way
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Low density Small screens QVGA 240x320
res/layout-small-ldpi
res/layout-small-land-ldpi
Low density Normal screens WVGA400 240x400 (x432)
res/layout-ldpi
res/layout-land-ldpi
Medium density Normal screens HVGA 320x480
res/layout-mdpi
res/layout-land-mdpi
Medium density Large screens HVGA 320x480
res/layout-large-mdpi
res/layout-large-land-mdpi
High density Normal screens WVGA800 480x800 (x854)
res/layout-hdpi
res/layout-land-hdpi
Xoom (medium density large but 1280x800 res)
Check this Android class:
http://developer.android.com/training/multiscreen/index.html
I'm looking to make an Android app that changes the look of the UI based on the device it's shown on (4 inch phone, 7inch tablet and 10inch tablet). I know you have the fragments API and it's probably that which I should use for this, but all the examples I've seen just have 2 activities sitting side by side and the code is a bit OTT for my needs (they have events passing between them etc).
Here is the comparison between a 4 inch device and a 7 inch device and how the different UI elements should move around (also note that element A can change design between the two devices).
Any ideas on how I would go about doing this, or if anyone has any sample code that would be fantastic!
I think you should probably design different xml for each size. You can use the qualifier in the layout dir for different screen size. http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources
You can use different directory for different size :
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and for more information :
http://developer.android.com/guide/practices/screens_support.html
Good Luck,,, :D
See also Fragments for Android 3.0+.