Android multiscreen different layoutfiles for tablets - android

I have to make an app which runs on 7" tablets with a resolution of 800x480 and also 1024x600.
The most importan tablet of both is the one with 1024x600 so I placed my layout files in a layoutfolder with the name "layout-sw600dp" and it looks good.
The problem now, is that the tablet with 800x480 resolution is also taking the "layout-sw600dp" folder and my layout isn't looking good. So I have to make some changes, but without destroying the layout for the bigger tablet.
Any idea what I can do?
thanks in advance
Frank

ok found a solution. The problem is, that both tablets are in the same android layout group. So I had to modify my layout in this way to fit for both. I had to use more dp settings and scaletype="fitxy" for images, instead of using "wrap_content".

Related

How to support different screensizes (different phones) with android

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

How to make layout compatible with different android devices in android studio?

I am designing an app with a .jpeg background and with text views on particular places on the screen. I designed this for my nexus 6 and used dp for the widths and heights of text views and margin-left and margin-top. What my understanding of dp is that it changes with every device according to screen size and density. So it should work on different phones according to the value of dp for them.
But this is not the case. When I run that app on a different phone (nexus 5) the layout is all messed up. I tried using the different resources and qualifiers for different screens (large, small, normal). But the problem still prevails. The app considers both nexus 6 and nexus 5 as large screens. How do i fix this?
this is not the best solution i guess.
i guess your layout is just on the layout folder. i don't know if the first device you tested the layout is large or small but what you should do is create another folder named layout-sw600dp. this folder is used by tablets. the folder layout is used my phones and smaller devices. you could also create the layout-land and layout-sw600dp-land folders for the landscape orientation.
dp do change depending on the device but if your layout gets messed up then i guess the layout called by that device doesn't fit its resolution. i guess dp becomes smaller if the device is bigger and vice versa.

Providing layout resource for Nexus4/Nexus7 against NexusOne/NexusS

I want to provide 2 different layouts for these 4 devices. I want Nexus4 (1280x720) and Nexus7(1024x600) use layoutA and NexusOne/NexusS (both 800x480) to use LayoutB.
I read the developer guide and still cannot figure out what kind of qualification I should specify to the different layout folders in "/res".
What's more, I even want the NexusOne/NexusS to use layoutA in portrait mode and layoutB in landscape mode.
In a summary, the threshold of the difference is the width and the density of the screen. I want to:
w>480dp use layoutA
w<480dp use layoutB
Can I achieve these goals at the same time?
Take a look at the docs - http://developer.android.com/guide/topics/resources/providing-resources.html
For N4/N7 have the resource directories
layout-sw600/layoutA
For N1/NS have the resource directories
layout/layoutB
Taking into consideration landscape and horizontal layouts, have an additional directory for N1/NS alone.
N1/NS
layout-port/layoutA
It's wall written in the tutorial. The folders you want are:
/res/layout-sw480 with layout A
/res/layout-land-sw480 with layout B
/res/layout-land-sw720 with tablet and nexus4 layout
Thanks for the gentlemen's answers above. I have tried many combinations of the qualifications and finally figured out the correct one:
/layout - small layout for short width as N1/NS-port, QVGA-port
/layout-w360dp - big layout for large screens N4/N7, and for landscape mode of N1/NS and QVGA
/layout-land - same as above
This works fine for me. The trick here is that QVGA is ldpi, N7 is mdpi, N1/NS is hdpi, N4/GN is xhdpi. I haven't tried it on a screen smaller than 320x480

Define drawable and layout for Galaxy Nexus

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 ...

Multiple layouts android

Im trying to set up my app with several layouts so that it will change depending on screen resolution. So i have a ldpi,mdpi, hdpi and a xhdpi. Everything seems to work in the sense that it changes, but to my question.
Is there a way to manually set which resolution to use which layout? for example now when i run it on my Galaxy nexus, it uses the hdpi layout and that just looks terrible, i want it to use xhdpi
regards,
Fredkr
Why don't you set up your hdpi layout to look the way you would like it to rather than trying to force another layout? Your app will automatically select the layout it should use based on the screen size and pixel density of your phone.

Categories

Resources