How to create different layout for Galaxy S3 and Nexus 7? - android

I have created an android application which works properly for nexus 7.
Inside resources folder, I have created two folders, layout, layout-land for Nexus 7" tab. Everything was working fine till date. Now I want to create a different layout for Samsung Galaxy S3. For that, I have created a folders inside resources with layout-large & layout-large-land. But, here is the problem. Now, for Nexus 7 also, the layout defined in layout-large folder is getting loaded. How to stop that? How can I create different layout for Nexus 7" tab & Galaxy S3 mobile? I have read Supporting Multiple Screens documentation. But I couldn't understand as the screen size for Nexus 7 is 1204 X 800 & screen size for samsung galaxy S3 is 720 X 1280.
How to create different layouts for different devices with different screen resolutions & display sizes? Also, based on device size, I want to change few values in my application. How to do that one?

According to the Supporting Multiple Screens
Qualifiers like small, normal, large and xlarge is for Screen Sizes, which means Nexus 7 will use the resources with large qualifier, if you provide. Therefore before you create the folder with large qualifier, Nexus 7 will load the resources from default layout folder. As for ldpi, mdpi, hdpi and xhdpi is for the screen density.
To solve your problem, you need:
put the layout definitions for Galaxy S3 into layout, and layout-sw600dp for Nexus 7. Please refer to Android Developers Blog: Getting Your App Ready for Jelly Bean and Nexus 7
put the resources (images or drawable stuff) for Galaxy S3 into drawable-xhdpi, and drawable-tvdpi or drawable-hdpi for Nexus 7.
Hope it could help you, and please let me know if you have any other problems :)
Here are some useful references:
What layout is suitable for 720x1280 Android devices?
Screen Width Qualifier

You need one for xlarge and xlarge-land aswell
Or you can do it programmatically by calling:
Display displayparm= activity.getWindowManager().getDefaultDisplay();
int width= displayparm.getWidth();
int Height= displayparm.getHeight();
and choosing layout from this info

you could create the layout by adding new folder under the res folder as layout-xlarge and layout-xlarge-large and u have to update the android manifest file as well to support the for higher resolution

I have developed an application where i support multiple devices with different resolution and densities. with nexus 7 and galaxy s3 also one among them. galaxy s3 and nexus7 will obviously take from the large screen folder if u have layout-large folder in your project. But galaxy s3 falls under large hdpi category and nexus7 falls under large-tvdpi category. so it will be of great use if you have layout-large-hdpi and layout-large-tvdpi for s3 and nexus7 respectively.

Related

how to differentiate 7" (1024*600) tablet and 10.1" (1280*800) tablet at design time

I am developing app for tablets which supports 7" 1024*600 resolution and 10.1" 1280*800 resolution. So in order to differentiate them I am making folder layout-large-mdpi for 7" and layout-xlarge-mdpi for 10.1". But while I run the app, it runs from layout-xlarge-mdpi folder for both the device. Can anyone please guide me on how to differentiate these two tablets through folders in xml?
Make two different for layout also one layout for 7Inch as layout-sw600dp and for 10'inch as layout-720dp. and in the images make drawable also as drawable-large-hdpi(7Inch) and drawable-xlarge-mdpi(10Inch).

Distinguish design layout for galaxy S3 and galaxy Note

How to make layout for galaxy S3 (720x1280 pixels) and galaxy Note (800x1280 pixels).
both are extra high density devices so i need to put two set of images for both devices in same folder drawable-xhdpi.
I dont know how device will detect different different images for both devices because both are from same folder.
please tell me how to make layouts or manage layouts for these two devices in a same application.
Thanks in advance.
You can distinguish between the devices using the -sw<N>dp qualifier, which discriminates devices based on their smallest-width attribute.
In your case, you will probably want to add a new folder called drawable-sw400dp. Drawables in that folder will qualify only for devices with a smallest width of 400dp or greater. Since the Galaxy Note is xhdpi with a smallest width of 800px, it will qualify where the S3 will not.

Samsung Galaxy Tab and Screen Density

As you know Samsung Galaxy Tab's (7.4") screen resolution is 1200x600 and dpi is 160 normally, but Samsung reports its density 240 dpi.
So, i created hdpi graphics for galaxy tab and put them in drawable-hdpi folder.
But i noticed that after install custom ICS rom to Galaxy Tab, galaxy tab starts to report its density 160 dpi. So it show mdpi graphics.
I wonder could i do something in my application to handle this special situation; because i know i replace drawable-mpdi graphics with drawable-hdpi graphics, lots of device will have problems with app, this time.
If it is only for the situation explained above, you can use the "Platform Version" qualifier. (Refer to Providing Resources)
drawable-v14 for ICS and accordingly for other versions. You can also use drawable-hdpi-v14 for fine grained control.
I take it you are talking about the GT-P1000, and it is the only exception to have HDPI density instead of MDPI for that size. I use drawable-large-HDPI for it next to a drawable-large-MDPI folder for all other similar sized tabs and thus have different resources for both.

android screen supporting for different resolutions in same density

I'm developing an application which supports xhdpi devices.
so I created layout-xhdpi and drawable-xhdpi folders to place my drawables
and layouts.but I'm having a problem when supporting different resolution in same density.
as an example samsung galaxy nexus and sharp IS003 detects same layout-xhdpi folder because it has same density but when I run the application in both devices,it displays buttons and
images at different positions because both devices got different resolutions.
am I doing something wrong? should I create different folders for specific resolutions?
I have read supporting multiple screens documentation and tried to declare layouts like res/layout-sw600dp/ but it wont detect for IS03.
Please help me to solve this problem.
why you kept drawable-xhdpi?. there is no android tablet with xhdpi.
check here:
all the 10 inch tablet is only mdpi.
if you check your device density it will show only 160dpi for tablet.
there is xhdpi device for normal phone nexus S ICS.
so move all your drawable-xhdpi to drawable-mdpi and check it will work.

Drawables and Layouts for Galaxy Tab and Motorola XOOM

I'm testing my app at Galaxy Tab and Motorola XOOM emulator skins, and I can't understand, why the drawables are taken from the wrong folders. I have drawable-xhdpi folder, where I store big size pictures. However, Tab takes drawables from drawable-hdpi, and XOOM uses the drawable-mdpi folder. So, how do I manage my resources? Thanks in advance.
In addition, it feels like view sizes defined in sp are not ported properly. I have some views which need to be 80sp x 80sp, on phones with mdpi and hdpi screens they look right, but on tablets they look too small. Why can this be?
However, Tab takes drawables from drawable-hdpi, and XOOM uses the drawable-mdpi folder. So, how do I manage my resources?
There is no single "Galaxy Tab" device, so I have no idea which one you are referring to there. The XOOM is an -mdpi device. I would expect that the Galaxy Tab 10.1 would be -mdpi as well. However, in the end, device manufacturers will choose values that they feel deliver the best results for existing applications.
GalaxyTab 7" use "-large-hdpi"; XOOM 10.1" use "-xlarge-mdpi".
check this post for details:
GalaxyTab, Motorola Xoom Screen Desity and Size
I have test with multiple screen resolutions and find out Android use the following qualifier for different screen resolutions:
240x320: -ldpi
320x480: -mdpi
480x800: -hdpi
GalaxyTab7.1 inches: -large
GalaxyTab10.1 inches: -xlarge
Hope this information is useful for you.
Galaxy tab (the old one, running Android 2.x) is indeed not xhdpi. I had success by using the "large" qualifier to identify tablets. Else you can always use an API qualifier such as v11 for Honeycomb only resources.
Rather than using the dpi qualifiers you can use screen size qualifiers instead, theres info here on exactly what tags you can use when selecting which resources to use,
http://developer.android.com/guide/topics/resources/providing-resources.html
It's important to understand the difference between dpi and screen size, dpi tends to be high on phones, like a samsung galaxy s2, but on the big 10 inch tablets it tends to be low(which makes sense if you think about it, the phones squeeze more pixels into a smaller space).

Categories

Resources