By following this tutorial, I created 3 different layout folders (over default layout folder):
layout-large
layout-small
layout-xlarge
In this way, some screens do not fit as I want.
For example, Nexus s, Galaxy Nexus and Nexus 4 preview seem to use the default layout, but it doesn't fit well.
Should I create other layout folders, for these devices (and others that I'm maybe forgetting)?
Nexus s, Galaxy Nexus and Nexus 4 are all "normal" sized devices (or large, i'm not sure). So the behaviour you're getting is "correct".
Have you tried to specify layouts according to the smallest width?
Something like layout-sw480dp, this should target the devices you want.
Related
Please Read the question carefully before marking it as duplicate
I have tried this SO Layout folders for Google Nexus 7 and 10, didn't worked for me.
I am developing an app which should work on both tabs and phones. I've created following resource directories:
layout-mdpi, layout-hpdi, layout-xhdpi, layout-xxhdpi, layout-xxxhdpi, layout-sw600dp, layout-sw600dp-land, layout-sw600dp-land-tvdpi (for nexus 7 land), layout-sw600dp-tvdpi (for nexus 7 portrait), layout-sw800dp, layout-sw800dp-land, layout-sw720dp, layout-sw720dp-land
**same for drawable and values
my problem is that in Nexus 10 it always takes from layout-xxxhdpi (which is certainly not for tab) instead of layout-sw720dp and layout-sw720dp-land.
Is there any way to create a separate folder for nexus 10?
I already have tried these with no result:-
layout-sw720dp-land-xhdpi
layout-sw720dp-xxhdpi
Possible solution is to go by screen size - layout-large and/or layout-xlarge.
Once I developed for highres tablets (10"), I had to go with layout-large.
Also you pretty much don't that number of directories, research about RelativeLayout, wrap_content, match_parent and density pixels
I got a problem related to the layout folder for some device.
So at first I had layout and layout-large folder. I only have 3 xml files for layout inside of these layouts.
layout folder has xml files with using Eclipse configuration of Galaxy Nexus 4.65" (720x1280 xhdpi)
layout-large folder has xml files using Eclipse configuration of 5.1" WVGA (800x480 mdpi)
I tested it on a small Samsung Galaxy Youth 3.3" (320x480), and it's using layout folder... I don't really understand about screen res, I read it in google doc but until now I don't really get enough of it. Google Nexus configuration looked fit for small screen so I chose it without enough understanding in resolution or screen size. Somehow, it fit well in my Galaxy Youth.
While for larger screen device I depend on layout-large folder, so I tested it with Galaxy Tab 7". It fit well too.
Problem arise when I tested it with Galaxy Note 2 and Galaxy Note 4 .. (for other devices I didn't test because I don't have them).
Galaxy Note 2 and Galaxy Note 4 seems to use layout folder not the large one (I'm sure it'll fit well in my layout-large).
I actually want 320x480 or smaller screen size devices to all use layout and any devices with larger screen should use layout-large. How to achieve that?
YOU CAN USE CODE TO SELECT YOUR DESIRED layout for specific smallest-WIDTH of DEVICE..IN
onCreate:
Configuration config = getResources().getConfiguration();
if (config.smallestScreenWidthDp >= 480) {
setContentView(R.layout.main_activity_LARGE);
} else {
setContentView(R.layout.main_activity);
}
the Document say about ( sw NUMBER dp) format :" The exact point of this switch will depend on your particular design—maybe you need a 720dp width for your tablet layout, maybe 600dp is enough, or 480dp, or some number between these. "
so you can put in res :
res/layout/main_activity.xml
res/layout-sw480dp/main_activity.xml
Look here: http://stefan222devel.blogspot.sk/2012/10/android-screen-densities-sizes.html
There is more information about screen sizes and densities of android devices
I will get straight to the point. I have my application finished and I am trying to get the layout to work on different screen sizes. My problem is with a small screen size, say 3.7" or 4". I have a layout-small,layout,layout-large, and layout-xlarge folders with different layouts for each. For Nexus 4,5, and 6, the small layout is associated with them, when I want "layout" as I used a bigger phone for those layouts.
I wanted to use the layout-small folder for Nexus One and Nexus S, as those are smaller phone and I used those emulators for the layout. For whatever reason, when I use a small phone like the Nexus One, the layout extends beyond the page while being associated with the layout-small folder, while when using the nexus 4 or 5 phone, the layout looks fine, while being associated with layout-small. It seems like Nexus One,S,4,5,6 are being shown as associated with layout-small, but are actually using layout. Any help would be greatly appreciated.
I should add that I tried doing layout-small,layout-normal,layout-large,and layout-xlarge, but everything that was associated with layout-small turned to layout-normal, and layout-small was completely dropped
Start with http://developer.android.com/guide/practices/screens_support.html You should also consider the orientation as a qualifier. The "small", "normal", "large", etc is not exact and you need to find out which it is for each device (emulator) you are testing with. Just as a test, create the folder structure with all qalifiers and have a single layout in each with a single text view that is hard coded with the resource path.
Example
res/layout-small-land/test.xml android:text="layout-small-land"
res/layout-small-port/test.xml android:text="layout-small-port"
res/layout-normal-land/test.xml android:text="layout-normal-land"
res/layout-normal-port/test.xml android:text="layout-normal-port"
i have a question about the app widget in android. I'm a litte bit confused, cause i define in the info xml (res -> xml) the values for width (250) and height (110) (http://developer.android.com/guide/practices/ui_guidelines/widget_design.html). Now i expected my Widget take the in the width 4 cells and in the height 2 cells.
I tested it with a Nexus S (HDPI), all works fine, i tested it with a Nexus 4 (XHDPI), all works fine, i tested it with an Samsung Galaxy Tab 10.1/Emulator tablets (MDPI), it doesn't work, Nexus7 (Emulator) (TVDPI) also it didn't work.
OK, I looked in the Menu and i see the system takes 3 and not 4 cells for the width.
Now my Question is there a way to define specific xml files for the tablets (please notice that i would support device with android 2.3.3) or am I missing something?
Have you tried putting your layout for the widgets into different folders, so that it will be rendered out differently on different screen sizes? For example, when supporting tablets you would have a layout-xlarge folder which contains the layout for your Widget on extra large screens. See here for more information about Tablet layouts.
I'm developing an app that must work for multiple device screens, so, I separated the drawable and layout folders properly: large-land, large-port, sw720dp and so on.
For devices like Nexus, from Google, I'm having a problem with its menu, that is in OS, not physical, like in others devices.
So, layouts that works well in devices like SIII does not work on Nexus, it seems like shrunken, because I lost a litte of its height.
Discussing with friends, we thought in set its layout programatically, but in a screen with various elements, it's bad to keep. Is there a way to organize this layout and drawable using the android's structure, like I did for others resolutions and sizes?
Thanks in advance.
for the nexus 7 from Asus it will use the drawables in folder drawable-xhdpi so put the drawables there ... and for icons use 48x48 size so they will look the same size as an actionbar icon ...