Android: Difference Between Large and Xlarge Layout? - android

I have an app that I am creating. I want to have this app support tablets, so I created a folder in my res: res/layout-xlarge/my_layout.xml. However, when I run my app on a tablet (defined as 7" or above) the layouts are not used from the layout-xlarge folder, but instead from the layout folder.
I then discovered that there were also layout-large layouts that I could use too. I haven't yet tried them, but I will.
I would like to know what is the difference between layout files, layout-large files and layout-xlarge files. Which one would be the best to use for tablet layouts?
Thanks!

From Android documentation - Supporting Multiple Screens:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Which one to use, as you can see, depends on the dimensions of the device you're aiming for. You probably want to build your app so it will support as much devices as possible.

In Android we need to maintain different folders for the layouts with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.
small Resources for small size screens.
normal Resources for normal size screens. (This is the baseline size.)
large Resources for large size screens.
xlarge Resources for extra large size screens.
Android OS select the specific layout it self by checking the compatible device and its resolution.
So, better to create folders to support in multiple screens

Related

Android 7.0 Settings> Display size set to small impact on current implementation

My current implementation to support multiple devices when specific layouts are needed for mobile, tablets (7' and 10') was to have separate layouts in layout normal, large , xlarge folders respectively.
However, from Android 7.0, user can change the display size. When display size is set to small, its causing it fall under large category and it start to pick large folder resources.
To solve this problem, i am planning to rename large and x large to 600dp and 720dp. As large and xlarge were intended to support 7' and 10' tablets.
Is this approach correct, will layout-normal, layout-sw600dp, layout-sw720dp will cover mobiles , 7' and 10' tablets ?
Thanks in advance.
Our conclusion is working on the basis of smallest width attribute gives the correct behaviour - layout-sw600dp, layout-sw720dp
Read more about smallest width -
https://developer.android.com/training/multiscreen/screensizes.html
Thanks.

Supporting different screens, based on the dimension or based on the dpi?

I use API 7. I know there are two ways for my question:
1- using the layout-small and layout-normal and layout-large and layout-xlarge.
2- using the sw-320dpi and like this.
When I see the all existing devices (tablet and phones) in the android studio, I understand it does not contain the all existing devices (tablet and phones) in marketplaces. Now I want know your experience about my question. If you want create an application that it uses the API 7, Which method you choose? I do not want link from other websites, I want know your experience about supporting different screens? What is the best way?
you use api level 7 so you should use :
layout-small, layout-normal, layout-large and layout-xlarge.
because using sw-320dp ... begins with android 3.2(api level 13)
Take a look :
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.
http://developer.android.com/guide/practices/screens_support.html
It's not sw320dpi, but sw320dp. This number doesn't represent screen density, but size in the same manner as small/normal etc.
See http://developer.android.com/guide/practices/screens_support.html
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

Button moves up when I launch app on Nexus4 ADV

I made my android app, a background, and some buttons. I run the app on my Galaxy S Device, and it's ok as I designed the buttons are where I put them. When I start the same app on virtual device Nexus4, the buttons always move a little up.
What is the cause? What can I do, so on all devices buttons to stay on the same place?
the problem might be that you may use your own defined sizes for buttons like
android:layout_width="80dp"
android:layout_height="40dp"
and layout_marginTop,Left,Rigth attributes
because supplying our own values varies for different screen orientations from small screen mobiles to large screen tablets
best culture the habits of using wrap_content,fill_parent,match_parent
and layout_weightsum for Linear layouts
As android is running on multiple devices with multiple screen with different resolutions, here is how to support them: Supporting Multiple Screens
Basically we have following screens resolution:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
to support them all, in Res folder we have to create folders depending what screens we want to support.
layout-xlarge
layout-large
layout-normal
layout-small
after, copy the your final layout_file.xml to all of them, open it in Graphical mode, and rearrange the buttons to look good on the screen. Depending on the resolution screen android will choose layout which is closer to device resolution . Just test it on different devices, or virtual devices to make sure it looks good.

Android not using right layout according to screen size

So I have two sets of layout, one for a 7inch tablet, one for a 10 inch tablet.
Configuration.SCREENLAYOUT_SIZE_MASK
shows large for the 7, xlarge for the 10 device. I created two folders, layout-large and layout-xlarge, but the 7inch device uses the x-large layouts (I even deleted the normal layout folder).
What could be my problem here?
EDIT: I also tried the new qualifiers according to http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts, making the layout folder for the 10"
layoutw1280dp
which the 7" cannot possiblys have, still the same.
Don't underestimate how many pixels these small screens can have. The Samsung Galaxy S3 has 720x1280 screen. That screen couldn't be larger than 7"
From the documentation:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Which tablet is it?
Sorry bothering you guys, obviously it was not an Android problem, but an Eclipse one, somehow the layout files within the folders got mixed up when I imported the project.

Android Images for various devices

I have question regarding Android Layouts.I have read the documentation of Layouts .My question is that while developing lets say if the images are placed in the folders named
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi
Does drawable-ldpi refers to the phones with smaller screen ,drawable-xhdpi for tabs and drawable-mdpi medium sized screen phones.
If not i have a image i need to be able to put into all types of devices namingly phone,tab
How can i do it.
usually, larger screens have higher DPIs, but that is not always the case. if you are trying to differentiate between phone and tablet screens, density is not the right way. use the following,
drawable: phones
drawable-sw600dp: 7" tablets
drawable-sw720dp: 10" tablets
alternatively, you can use the screen size: small, medium, large, xlarge. e.g., drawable-large. from the docs,
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
http://developer.android.com/guide/practices/screens_support.html
Googling Android xhdpi brings up the Android resource on how you should use these:
http://developer.android.com/guide/practices/screens_support.html
DPI means how many dots per inch there are. Some small phones fit lots of dots in, which gives them a high DPI. You should provide different sized images for different resolutions. Google recommends creating images in the ration of 3:4:6:8 for l, m, h and xh DPIs.

Categories

Resources