I made an app , and i am also using layout, layout_large,layout_x large folders for XML.
but when i test my app on 3.7 and 4.7 inch device...they both take XML from normal layout size folder and take layout-large XML for 7 inch tab.
so what should be done for layouts between 3.7 to 5.5 inches??
Help appreciated.
if your min sdk over 13 then try to work with layout-sw600dp... and not with layout-large ..
For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/.
Take a look :
http://developer.android.com/guide/practices/screens_support.html
In addition to layout folder try using density dependent layout.just as we use for drawables.
eg.hdpi,xhdpi,xxhdpi.
Related
I'm working on android application and got in trouble of multiple screen support. I developed the app for 1080x1920 and when i tested the app on my friends Micromax Unite 2 with resolution of 480x800, it was something else. So i made two folders in the layout as:
layout-1080x1920
layout-480x800
thinking that the 480x800 device will pick up the layout-480x800 folder. But no it used the layout-1080x1920. So what should i do? So that the device having resolution of 480x800 works on layout-480x800
I suggest naming the folders as such:
layout-sw600dp
Where sw600dp means Screen Width 600dp. This layout folder will be used by devices with screen widths of 600dp or more (typically all 7-10 inch tablets, or just very dense screen). And when you are targeting for the phone use just the layout folder without any specified criteria. All phones not matching the sw600dp will use the default layout resources. Possibly also consider using
layout-sw600dp-port
if you need to use specific layouts for portrait orientation, likewise you can do
layout-sw600dp-land
if you wanted to specified layouts for landscape.
The link cricket_007 provided is where I learned this information
Note that 1080x1920 equates to about 540 x 960 dp in dp measurement, which is why I suggested to use the particular 600dp for width
giving the folder names pixel according to android screen support dev page. Even if you know all possible resolutions for every device, the android system takes those *xml files/drawables etc specified by their DPI, not PX. Those dpi resolutions still can change on runtime, such as, when your activity uses a tool bar (which is not part of your dpi resolution). Name your folders layout-xlarge, layout-large, layout-normal, layout-small for *xml layouts. I suggest to put 4 different xml files with same name in each of them and try it again for different devices.
I am new in android development and I need to design layouts for 8 inch and 10 inch tablets in landscape mode. Reading all the docs it is showing for 7 inch and 10 inch tablets. But what about 8 inch tablet then? And moreover do I need separate drawable for them?
Use NinePatches to generate images for different dens.
http://romannurik.github.io/AndroidAssetStudio/nine-patches.html
and instead of using dp in width and height,try to use weightSum and layout_weight.
Tell me if it helps. :)
Android allows you to specify a different layout for up to 4 device classes. You should not concern yourself with how these classes map to actual devices.
As for need ping separate resources for each, it depends. If you care a lot about the quality of your display (like a lot of people) then yes, you will need different sets of resources (e.g. Images) for each class of layout. However, if your drawables are just solid color or gradient based backgrounds then you can define them only once and the platform will scale them for you.
for images create drawable folder as: drawable-large-mdpi
As i new in android development i just want to know is there any way to develop Android application for different screen sizes ?
help me.
Thank you in advance
Just add this in your project.
res/values/main.xml
res/values-sw600dp/main.xml -> 7+ inches
res/values-sw720dp/main.xml -> 10+ inches
Create this folder and just copy your xml file in all the folders.
Put your main.xml in those folders:
res/values/ //your default values (in your case for phones)
res/values-large/ //specfic values for relatively big screens
res/values-xlarge/ //specific values for really big screens
large: Screens that are of similar size to a medium-density VGA
screen. The minimum layout size for a large screen 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 an xlarge
screen 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.
see more infos here: http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes
Google provide good article how to support multiple screens
http://developer.android.com/guide/practices/screens_support.html
General advices:
use layout - for for mobile phone layouts
use layout-sw600dp folder for 7inch tablets layouts
use layout-sw720dp folder for 10inch tablets layouts
use dimens.xml in values folder to define dimentions for your UI
you also can use
values-sw600dp and values-sw720dp with its own dimens.xml file for 7 and 10 inch tablets
Writing apps for multiple devices requires one to have good knowledge on basic concepts like : what is Dpi, Screen density , Orientation etc.
Article below is good place to start for:
Supporting Multiple Screens
http://developer.android.com/guide/practices/screens_support.html
I'm implementing an application and I want to support all screen sizes. I have 4 layout folders: layout, layout-small, layout-large and layout-xlarge.
Which screen size supports the standard layout folder? Is it even necessary?
Which screen size supports the standard layout folder?
In your case, it will depend on what files are in what directories.
Let's say that you have main.xml in layout/, and not in any of the other three candidates. Then, setContentView(R.layout.main) will use the copy in layout/.
Now, let's say that you add a revised version of main.xml in layout-xlarge/. On an -xlarge device, Android will use the layout-xlarge/ version of main.xml, and on other screen sizes, Android will use the layout/ version of main.xml.
Now, let's say that you add a third main.xml version, this time in layout-small/. Android will still use the layout-xlarge/ copy of main.xml for -xlarge devices. However, all other devices will use layout-small/, and the layout/ copy of main.xml will be ignored. Android will not try to shrink a layout from a larger size (e.g., -xlarge layout on a -normal device), but it will try to expand a layout from a smaller size (e.g., a -small layout on a -normal device).
What I tend to do is use layout/ for:
Layouts that do not need different versions for different sizes
Layouts to be used on -normal devices (as I rarely support -small)
I then use layout-large/, layout-xlarge/, or their Android 3.1+ replacements (e.g., layout-w720dp/) for layouts to be used on larger screen sizes.
However, that is just my particular style, and you are welcome to do what you want, within the usage rules described above.
using modern notation is a better solution:
/layout // for phones
/layout-sw600dp // for 7 inch tablets
/layout-sw720dp // for 10 inch tablets
In popular:
Mdpi screen smartphone is cheap
Hdpi screen smartphone is expensive.
If you use layouts only mdpi folder, this layout will be used for all screens
Legend:
layout-small = ldpi
layout = mdpi
layout-large = hdpi
layout-xlarge = xhdpi
[Update] Thanks Kai, this issue is caused by #dimen/activity_vertical_margin in XML. The default value of dimens.xml is 128dp in values-sw720dp-land. (others are 16dp).
I create a new empty project, and run it on Android 4.2 and 2.3 (with Xlarge screen 10.1" WXGA 1280 x 800). Here are the screen capture. Why does "Android 4.x" and "XLARGE" screen cause the content indention?
(Android 2.3)
(Android 4.2)
Besides using the Xlarge qualifier for layouts you also can use version numbers. I'm not sure why it would be different if it is the same resolution and screen size but you can also use version qualifiers for your layout folders.
So, you could have one that is in res/layout-v15 (4.x) and one in `res/layout-xlarge(since its working in 2.3)
This should make devices with 4.x use use the layout-v15 and anything below with the appropriate screen size would use layout-xlarge. I don't know if this will take care of all your problems but it may help.
It looks like a very larg marginLeft and marginRight is applied to the 4.x version of the dialog:
You should check your XML and image resources to see if different margin is applied for different API level.