I have the following structure of layouts for a particular activity:
Now when I check the specs of Micromax Funbook over here I get to know it is a 7 inch tab with resolution of 400X800
The docs state that for seven inches tablest I should use sw-600dp qualifier. However I am puzzled as the concerend tablet is taking layouts from sw-480dp folder.
When I test on a Nexus 5 device which is 4.95 inches and thus should either refer to sw-480 or sw-600 I see it takes the layout from layout folder without any size qualifier(mock_layout.xml - without qualifiers)
What could be wrong? What is the proper way of doing this?
Related
For a school project I have to create an app, but now I have a question. I made a layout and changed the screensize to see if the layout was still the same, but it wasn't unfortunately. I hope someone can help me with this. Here are some screenshots:
The first picture is 5.5 inch and the second picture is 5 inch
For this view I think that the better way to make the view resize, depending the device screen, is working with LinearLayout and weight_sum, giving a layout_weight value to each child depending the size of each.
Here a good tutorial.
You can separate difference mobile phone using its screen size, android os etc...
Folder name like:
res/layout-hdpi -for high density device
res/layout-xdpi -for high density device
res/layout-xxdpi -for high density device
or
res/layout-w320dp-h640dp
or
res/layout-sw600dp -for tablet 7inch
I'm creating an application for smartphone tablet and televison.
I'm creating my different displays, but I can not differentiate the tablet from the television.
I read https://developer.android.com/guide/practices/screens_support.html
I have tried many things, large,xlarge sw720dp, W1024dp.. but nothings works. I work with the emulator.
AndroidTv 1080p API 25, Résolution 1920*1080:xhdpi
Nexus 5 API 24 Résolution 1080*1920:xxhdpi
Nexus 7 1200*1920 xhdpi
Thanks for your help !
The documentation you want is here: https://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
The important parts of this page are Table 2 (configuration qualifier names) and the section titled How Android Finds the Best-matching Resource.
Reading these, it is clear that you will use the Smallest width qualifier to differentiate between phone and tablet devices, and the UI mode to differentiate between televisions and non-televisions. This directory structure should work:
res/
layout/
layout.xml (default (i.e. phones))
layout-sw600dp/
layout.xml (non-televisions 600dp or wider (i.e. tablets))
layout-sw600dp-television/
layout.xml (televisions 600dp or wider)
Because the Smallest width qualifier has a higher precedence than the UI mode qualifier, if you tried to just use layout-television you would find that your TV still used the -sw600dp layout.
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 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 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.