Which layout should I use for HVGA screen? - android

Which layout should I use for HVGA screen? For a small screen, I put all my XML files in layout-small directory. Similarly for devices like Nexus S and Samsung Galaxy S which have a resolution of 480 x 800. I put all my XML files in the layout directory.
But for HVGA I didn't find any solution. Where to put the XML file for the HVGA device?
Is there any option like layout-small that I can do for HVGA devices? When I run the for HGVA device it takes the layout from the layout directory but as the resolution for HVGA devices is smaller than Nexus S devices, the layout does not properly appear. So I want to know.

To target HVGA 320*480 use:
layout-normal-mdpi
At the same time to support WVGA screens and i.e. Galaxy Tab you need:
layout-normal-hdpi
folders.

According to this
Normal: Screens that are of similar size to a medium-density HVGA
screen. The minimum layout size for a normal screen is approximately
320x470 dp units. Examples of such screens a WQVGA low density, HVGA
medium density, WVGA high density.
MDPI: Medium-density (on traditional HVGA) screens; approximately
160dpi.
You should try: drawable-normal-mdpi

you can use the layout of layout-large
you can refer following link ....
http://developer.android.com/guide/practices/screens_support.html

Related

How to know which drawable resource to load in graphical layout?

In my XML Graphical Layout I set the screen to 3.2in HVGA slider (ADP1) 320x480 mdpi.
But it still uses my hdpi-drawable resource. I checked my mdpi folder and my scaled image is there 70x70. But it uses my 105x105 image in the hdpi folder. Oddly, when I use the xhdpi and hdpi screens it works fine, they use their own drawables.
And another questions why does 10.1in WXGA (Tablet) 1280x800 mdpi use mdpi resources considering it is a tablet and has high resolution?
Sorry for my english, any help will be appreciated.

How to include 10" and 7" layouts properly

Nexus 7: 7" 1280x800
Galaxy tab 10.1 10" 1280x800
I want my app to run on 7 and 10 inch tablets. As far as I know, I have to include these layout folders in my app:
for 7 inch tablets
layout-sw600dp
layout-sw600dp-port
for 10 inch tablets
layout-sw720dp
layout-sw720dp-port
It runs fine on the nexus 7, but loads the sw600dp layouts on the 10" tablet.
If I include these default folders:
layout
layout-port
10" galaxy tab loads layouts from these.
If I only include the default layout folders and the sw600dp one, it crashes on the nexus7.
How am I supposed to support phones, 7" tablets and 10" tablets, if the 10" galaxy tab won't load the sw720p layouts?
edit:formatting
The problem was, that I had no default layout folder.
I tried getting by, using only the sw600dp and sw720dp folders. I still have no idea why they don't work, but I don't care. I can't use swxxxdp <3.2 anyway, so screw that.
So if you want to write an app, that has to support phones(2.2+), 7inch tablets and 10 inch tablets, use the following oldschool stuff:
layout this is the default, it is needed even if you don't plan to support phones!
layout-large for 7" tablet (works on emulator and nexus7)
layout-xlarge for 10" tablet (works on emulator and galaxytab10.1)
Other people have came to the same conclusion too.
I am also facing such problem in my application. But I found a good solution for this.
I have only one layout for tablet and directory name is layout-sw600dp.
Now, when part came to height and width problems, I have created several different values directory in which i place dimensions and font size and other stubs. So there will be no constant value in layout of tablet screen.
androd:layout_width:"60dp" // i drop this scenario
androd:layout_width:"#dimen/tab_width" // i used this scenario
and your values directory name will be like
values-xlarge
values-large
All the values will be fetched from your values directory. It will not create different layout, but one layout can be used multiple times.
Following are words of Developer.android site.
Configuration examples
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Using the size qualifiers from table 2, your application can switch between your different layout resources for handsets and tablets using any number you want for width and/or height. For example, if 600dp is the smallest available width supported by your tablet layout, you can provide these two sets of layouts:
res/layout/main_activity.xml # For handsets
res/layout-sw600dp/main_activity.xml # For tablets
===
In this, you can see that, layout for 1280*720 is under layout-sw720dp so instead of creating layout-normal-xlarge you should use this thing which lets you to decide differences. Instead of identify differently using layout-large-mdpi and layout-large-ldpi, are't you just identify by its smallest width? Because, android providing drawables directory for different images, only thing is its resolution. And you have above solution.
Edit
Then you must have to develop different layouts. No other option. I found at http://jamil.fluidsoul.net/2011/03/06/creating-android-applications-for-multiple-screen-sizes.
Low density Small screens QVGA 240x320 (120dpi):
layout-small-ldpi (240x320)
layout-small-land-ldpi (320x240)
Low density Normal screens WVGA400 240x400 (x432) (120dpi):
layout-ldpi (240 x 400 )
layout-land-ldpi (400 x 240 )
Medium density Normal screens HVGA 320x480 (160dpi):
layout-mdpi (320 x 480 )
layout-land-mdpi (480 x 320 )
Medium density Large screens HVGA 320x480 (160dpi):
layout-large-mdpi (320 x 480 )
layout-large-land-mdpi (480 x 320)
Galaxy Tab ( 240 dpi ):
layout-large (600 x 1024)
layout-large-land (1024 x 600)
High density Normal screens WVGA800 480x800 (x854) (240 dpi):
layout-hdpi (480 x 800)
layout-land-hdpi (800 x 480)
Xoom (medium density large but 1280x800 res) (160 dpi):
layout-xlarge (800 x 1280)
layout-xlarge-land (1280 x 800)
Yes, you should use layout-dependent folders but also make sure any device independent layouts go in your res/layout folder.
This is mentioned on the Android developer site but to reiterate their point, if you have a layout that is only available in an layout-xlarge folder on an app that supports say large and normal sized devices as well, the app will crash as smaller devices will not be able to find any match for this resource.
Here is a good folder structure, start with:
res/layout
Keep a device-independent layout in there, you can avoid this if you are accounting for every possible qualifier type but this is still the safer option.
If you want to add specific layouts for say 7 and 10 inch tablets, use all of the following:
res/layout-large
res/layout-xlarge
res/layout-sw600dp
res/layout-sw720dp
res/layout-sw800dp
And so on for any specific device screen widths you want to support. It should be noted that sw600 supports the smallest possible width, so avoids the use of the screen width when the device is held landscape. Using the swxxxdp qualifers are preferred but these were added in API 13 so you will still need large, xlarge for older Android OS.
Regarding use of the dpi, be aware that if you ONLY set one density qualifier for a size, so layout-large-mdpi for example, then any devices that match the large qualifier will use layouts from here instead of another folder, this is due to the Best Match criteria, which you can read about here. It will match it as a large device before it will match the density so non-mdpi density screens will still use these layouts.
To counter this, you will have to include folders for whatever other densities you support as well, so layout-large-hdpi following on from the above example, and include in this folder hdpi versions of layouts that you have used in the mdpi folder if you require them to be different.
Avoid duplicating your layouts as well of course, don't copy device-independent layouts into every unused folder if you only need them in res/layout, try and only keep the layouts that need these qualifiers in the folders and organise them properly, making sure your folders are named with the qualifiers in the right order of precedence to prevent using the wrong folder for a density/size combination.
This is very strange, since you are doing the correct thing.
The sw600dp qualifier should be selected by the Nexus 7.
If available, the sw720dp qualifier should be selected by the Galaxy Tab.
Are you sure it crashes when trying to find an appropriate layout? Android may find the correct layout, but something in the layout xml file may be missing and the crash is caused by that.

Android layout editor devices not holding their place for each different layout

I am trying to design different layouts for different screen sizes. I have created layout files for sw240dp, and I am now trying to design layouts for sw480dp. My problem involves the list of devices in the layout editor. I am trying to select a 3.7 inch device to design on, but the software keeps jumping over to the sw240dp layout file every time I select the 3.7 inch device for sw480dp. I don't understand what I'm doing wrong here. Is there something wrong with my eclipse software, or am I doing something wrong?
What resolution and density are you selecting for the emulated device? The DP is determined by the density and resolution. So for 480 DP, here is the mapping from density to required pixel resolution:
MDPI (160) : 480px
HDPI (240) : 720px
XHDPI(320) : 960px
So if you're picking a 3.7" 480x800 device at HDPI, that's not going to fall into the sw480dp bucket. You'd need to create it as an MDPI device (i.e. density of 160).

support for multiple resolution android

My app has 2 different resolution support, 480x800 and 320x240, i have created folder for them for instance layout-normal-hdpi and layout-normal-mdpi. But somehow emulotor is not picking up the ui for hdpi. I have created different layout aswell.
the way i am dealing with multiple screen is this way and its working fine.....if any one has improved wayso do guide me
Screen size 480x800
layout-normal-hdpi-480x800
drawable-normal-hdpi-480x800
Screen size Galaxy Nexus---
though its size is 1280x720 but in actual due to system bar its dimension(screen size) differs
layout-normal-xhdpi
drawable-normal-xhdpi
Screen size Note 5.3---
layout-normal-xhdpi-1280x800
drawable-normal-xhdpi-1280x800
Screen size S3---
layout-normal-xhdpi-1280x720
drawable-normal-xhdpi-1280x720
Screen size 7inch tab 2 supporting OS version 3 and above---
dont write dimension 1026x600 bsz in actual due to system bar its dimension(screen size) differs
layout-large-mdpi
drawable-large-mdpi
Screen size 7inch tab p1000 etc supoorting os verion less than 3---
layout-large-hdpi-1024x600
drawable-large-hdpi-1024x600
Screen size 1280x800 tab 10.1,10.2,note 10.1 etc---
you can add dimension if you want other wise it is fine
layout-xlarge-mdpi
drawable-xlarge-mdpi
From the documentation:
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
layout-normal-mdpi does not exist. Use layout-mdpi instead.
For reference: http://developer.android.com/guide/practices/screens_support.html
The Api level must also support this: Android - layout-large folder is been ignored
Handling different resolutions can get tricky on Android.
The one true resource for this is the official site:
http://developer.android.com/guide/practices/screens_support.html
It sounds to me like you might be confusing the size with the pixel intensity here.
Try to create the folders:
res/layout-sw480dp/main_activity.xml //for the large screen
and
res/layout-sw320dp/main_activity.xml //for the small one
Do you also have different drawable resource folders? Did you manage to get them to work?
Android Support Multiple Screeen
for tablet
Resolution 1280x800/1280x720
values-sw720dp
drawable-sw720dp
layout-sw720dp
Resolution 1024x600
values-sw600dp
drawable-sw600dp
layout-sw600dp
Resolution 480x800(twinner resolution, mdpi in tablet & hdpi in mobile)
values-large-mdpi
drawable-large-mdpi
layout-large-mdpi(incase you want to make separate layout)
for moblie
Resolution 1080x1920
values-sw360dp-xxhdpi/values-sw360dp-notlong-xxhdpi (when 768x1280 is used)
drawable-xxhdpi/drawable-sw360dp-xxhdpi/drawable-sw360dp-notlong-xxhdpi(when 768x1280 is used)
layout-sw360dp
Resolution 720x1280
values-sw360dp-xhdpi
drawable-sw360dp-xhdpi
layout-sw360dp
Resolution 768x1280
values-sw360dp-notlong-xhdpi
drawable-sw360dp-notlong-xhdpi
layout-sw360dp
Resolution 540x960
values-sw360dp-hdpi
drawable-sw360dp-hdpi
layout-sw360dp
Resolution 480x800
values-hdpi
drawable-hdpi
layout-hdpi
Resolution 320x480
values-mdpi
drawable-mdpi
layout-mdpi
Resolution 240x320
values-ldpi
drawable-ldpi
layout-ldpi
tags to add in manifest if your app needs to support full hd device only
for 1080x1920
<screen
android:screenDensity="480"
android:screenSize="normal" />
Courtesy: (Maulik Joshi)

How does Android decide which layout folder to use?

In my application I have 3 different layout folders:
layout
layout-large
layout-xlarge
I did this according to the available Android device screens, described here. So I thought that the screen size in inches is the only thing that is used to decide which layout folder to use. But recent tests with various 7 inch emulator showed that sometimes the layout and sometimes the layout-large folder is used. So can anybody tell me which other factors are used?
7 inch Android tablets are HDPI and large.
xlarge didn't exist at the time they were made, and although most of them have pixel densities around 160 (MDPI) they present themselves as HDPI devices because it looks better.
So the 7inch tablets don't quite fit into the resources system properly, because there wasn't really a way to fit them in prior to 3.0 which introduced new screen-size qualifiers.
I think size in inches is the only thing that matters. There was a question on here a while back where someone has having some odd results with trying to make emulators pick from the correct layout folders for 7 inch devices. I have a Galaxy tab though and it will always take from layout-large, or layout-hdpi.
Edit: perhaps I was incorrect it seems that type of screen and pixel count may matter too -
* small: Screens based on the space available on a low-density QVGA screen. Considering a portrait HVGA display, this has the same available width but less height—it is 3:4 vs. HVGA's 2:3 aspect ratio. The minimum layout size for this screen configuration is approximately 320x426 dp units. Examples are QVGA low density and VGA high density.
* normal: Screens based on the traditional medium-density HVGA screen. A screen is considered to be normal if it is at least this size (independent of density) and not larger. The minimum layout size for this screen configuration is approximately 320x470 dp units. Examples of such screens a WQVGA low density, HVGA medium density, WVGA high density.
* large: Screens based on the space available on a medium-density VGA screen. Such a screen has significantly more available space in both width and height than an HVGA display. The minimum layout size for this screen configuration is approximately 480x640 dp units. Examples are VGA and WVGA medium density screens.
* xlarge: Screens that are considerably larger than the traditional medium-density HVGA screen. The minimum layout size for this screen configuration is approximately 720x960 dp units. In most cases, devices with extra large screens would be too large to carry in a pocket and would most likely be tablet-style devices. Added in API Level 9.
If you happen to have folders with more than one qualifier like layout-large-mdpi etc you have to pay attention to the precedence order also. this page should help out.
According to Google's android screen support guide res/layout is used for normal screens and is the default folder in which the OS looks.

Categories

Resources