Android small screen size issue - android

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"

Related

How do I get specific xml layouts for specific phone screens in Android Studio

So I'm creating different xml files for different phone screens in Android Studio.
I tried a number of methods for creating xml for different screens.
The first one was 4 folders layout-small, large, normal and xlarge it worked for the big tablet screens except for Nexus one of size 480 x 800.
so I created a folder called layout-w320dp and it worked but it overrided my large and xlarge xml files.
As in when ever I click for tablet screens it brings up the w320dp xml file instead of the xml in large and xlarge folders.
So I created the other folders w480dp, w600dp, w720dp but using xml files messes up everything but if I don't use a xml from these folders it assigns the w320dp one to the tablet screens.
My toolbar for phone screens and xml is like this. It's assigning ones I don't want to phone screens. How can I override it and say for example this xml has to match with this specific phone screen size? Right now it's using XML and trying to fit it to a phone size that messes up everything.
Is there a way to assign a specific xml to a specific phone without it doing it for other phones?

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.

How to make my android game fit to all screen resolution?

I wanted to create a small game on android and then I realize that there is a problem with a screen resolution. I don't know how to make my game's control (Buttons, Textview, etc) will look good to all the screen resolution like (tablet and normal android device) that have different pixel. Like if I design layout for android phone and then if I run it on tablet then buttons, or any controls will look small. So the question is that how to make it (all controls) look more fit and good for any different pixel or resolution device?
You have to create seperate layouts for phablets tablets etc. create 5 folders under res directory.
layout-ldpi
layout-hdpi
layout-mdpi
layout-xdpi
layout-xxdpi
Then copy your file which by default in your layout folder and paste it in a all above folders. Then you have toh manually set the contents for different views . It is a very very boring tedious task

wxga android layout >600dp

I have an andoid layout which I want to display on tablets and phones.
I've created folders and layouts for
layout
layout-land,
layout-sw600dp,
layout-sw600dp-land,
layout-sw720dp,
layout-sw720dp-land,...
For most screens this works ok until I load a 4.7 wxga screen
I understand the relationship between density and size but what am I supposed to do to build a consistent layout when a wxga screen wants to run use the sw720dp layouts ?
If I specify text size based on a dp specific folders xml layout I simply can not get what I want. Am I missing something fundamentally simple . How can I make this layout work on a small screen with high pixel density and a large screen with the same number of pixels?
Here's what it looks like
edit : not enough reputation points to post images ;( post almost pointless now
It would be good to know what device is it. Especially its dp resolution. If you know it then you can create a layout-swXXXdp folder for it. If you don't know then I propose to put something in the layout files and check which is loaded on that device. E.g. in layout folder put a TextView with text "layout normal", in layout-sw600dp put a TextView with text "layout sw600dp" and so on. Please note that you can use other numbers as well for the layout folder name like layout-sw456dp.
I think in this way you can find the proper layout folder for that device.

Different InfoWidget.xml for App Widget

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.

Categories

Resources