problems with screen sizing for app - android

So I'm going through the main layout for my app and I have one layout folder "layout" the activity for my app has way to many text views and buttons on it to be able to use a relative layout with moving 1 thing and messing up the entire layout. I've been trying to figure out a way to just force the app into screen compatibility mode with my current layout (frame layout with just using margins) and it's displaying all messed up and nasty.
Does anyone know of a better way to support different screens?
Also, the answer to your first question is:Yes. I have gone through the Supporting multiple screens and screen compatibility mode in the documentation.

Use the nested layouts.For 10 inch tablet you have to specify layout-xlarge
For 9 inch tablet specify layout-sw720dp
see the below link for more details
http://developer.android.com/guide/practices/screens_support.html

my suggestion is to use nested linear layout and for different screen sizes you have to create different layout folders in your app such as layout_small,layout_large,layout_xlarge,layout_land then copy your xml files into these folders and make changes based on that

Hi williams you can create different layouts for screen sizes such as
layout-large,
layout-small,
layout-xlarge ,
So u can manage the screen sizes by creating different layout folders. And then copy your layout XML files to different layouts and you can modify the text fields , buttons ..etc as the screen size .

Related

Constraint Layout - Different set of Folders to be supported

I am trying to Implement Login screen for my Application and finding it confusing the different screens to be supported. I want my application to work on all sets of Phones and tablets of varying screen size and density.Can someone please suggest on what all screen sizes i need to design my layouts for in Constrain Layout.
In some posts they mention to design for
1. layout
2. layout-sw320dp
3. layout-sw480dp
4. layout-sw600dp
5. layout-sw720dp
is it enough if i design layout for above screen or do i need to add some other densities.
Create different layout folder for different screen size.
Try this
https://mobikul.com/make-layout-multi-screen-resolution-android/

Using layout in android xml

Which is the layout to use which doesn't have a difference in different screen sizes. Linear layout or relative. I had a relative layout and when I run the app on a 4' phone, the icons were way closer. In a 5' phone the icons were a bit away. What's the best way to have a constant XML which doesn't change by screen size.
For example.
I had this app in linear layout which contained 3 images in horizontal orientation. In the design view the icons were perfectly same and equidistant. But on the device, the third icon was smaller. Why
You can't achieve perfect layout for every device with just single layout file. For best results you should make different layout files for different folders used with images designed accordingly. For more information read Android Developers' tutorial from the following link
Supporting Multiple Screens
Over and all, you need to create different layouts/drawables for supporting all the screens. It depends on your requirement, say for example, if you would want to include 2 buttons in small screen and 4 buttons on large screens then obvious you have to create different layouts.
If you would want to display same number of buttons in all screens then I would suggest you to prepare different set of images/drawables and include them in your project. Here you don't need to do anything other than placing images in particular drawable folders.
One more thing, If its a plain background then you can create 9-patch image so that it can stretch with whatever size you want or your device supports.
More study:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/training/multiscreen/screensizes.html
http://developer.android.com/training/multiscreen/screendensities.html
http://developer.android.com/training/multiscreen/adaptui.html

How can I fix android tablet's width and height

I am making android application in tablet using fragments so that I arranged 8 buttons vertically in 10.1 tablet it is showing fine but in 7.1 tablet only 5 icons it is showing.
So How can I manage height and width properly in all tablets ... please help
Remember to write different xml layouts (with same name) and place to different folders: layout-large, layout-normal, layout-small and layout-xlarge. Same is with drawables (different size images) and values (different type padding and other values). These folders are for different phone/tablet types with various resolution and screen size. If you do it, then you can easily manage layout for small device and not touch big screen devices. Device is picking xml file automatically so it's good practice to place xml files in different folders for various phones.
More information you can find in http://developer.android.com/guide/practices/screens_support.html
You can use different layout for different screen sizes. You can also add different buttons and other drawable also. Please see the link
Supporting Multiple Screens
You can write different xml layouts using different folders:
For example:
res/layout
res/layout-sw600dp //used by 7''
res/layout-sw720dp //used by 10''
Also you can use the same layout with the same component but with different dimensions.
You can use #dimen/my_dimen notation, and then put your my_dimen in different folders like:
res/values/dimens.xml
res/values-sw600dp/dimens.xml
and so on..
Official doc: http://developer.android.com/guide/practices/screens_support.html

Android: support multiple screens

I am trying to make a application in Android. I want that it should be able to run on multiple phones of different screen sizes, so i studied support multiple screen on developers and according to that i have to create 3 different xml files for supporting three different screen sizes and also 3 different types of images for each type of xml file. But on a blog i get the idea of doing this by using current screen size method. So i am confused what i should do. means which is optimized and performance increasing way. And which one will be more perfect for supporting all types of screen(except extra large screens)
Defining height, width and other parameters in the XML file is the better option rather than on run time.
Because XML files works as metadata (data carrier) to the activity and avoids alot of confusion when onCreate mothode in called.
Plus, create different folders for image quality (hdpi,xhdpi,ndpi,ldpi)
7 inch device use mhpi
10 inch devices use hdpi and xhdpi
While NEXUS tabs use hdpi and xhdpi irrespective of their size.
Mobiles use ldpi and ndpi.
Beauty lies here is that android device automatically pick-p the suitable content when found, i.e layout and image.
If not found it would first search other Layout folders,e.g a layout not found in x-large folder then it will search in large,then medium, small, which one of them suits the best ,(if a layout is not found in its respective folder).
Nexus will create alot of trouble for you.
To check how your layout would look on different devices, try using the options, which tells you how it would look on that device with those height width, present in the Graphical (view of a ) layout.
You can use three different layouts for different screen sizes ,and android will pick the suitable layout , but Using three different layouts for each type of screen format will not be a good idea , because it will cause problem in handling all layout , if screens are less then its fine but if number of screen increases it will get difficult . Like if you forget to add change in one of the screen size it shall crash with any exception .
What you can do is keep images of different size in different folders and practice layout to make standard in one layout by using layout weights , and margins in in dp .
See my this answer
Table Layout spacing issues
and check this layout will look similar for all screen sizes.
If your design is same for all screens sizes you can use dp and have only one xml for all screens.
But you should support icons for all screens.
I think it's less confusing David Ohanyan way, but forgot to say something...
Whenever you can, use styles in your xx_layout, images, etc, so you'll have 1 layout.xml and 3 styles files inside folders: values, values-small, layout-large.
At least for me, it's less confusing than opening 30 different layout files.

Best way to define Android layout files for multiple devices?

What is the standard/best way to define sizing for elements in Android layout files to account for Android devices with all types of screens?
For example: I've been using a LinearLayout to arrange multiple child elements (TextViews, Buttons) one after the other horizontally or vertically for a ListView. However, on a smaller device, I may want to scale the elements down or shrink some elements but keep the others fixed.
I'd appreciate input. Thanks
There's an entry in the android dev guide for that: http://developer.android.com/guide/practices/screens_support.html
You can use drawables in drawable-hdpi, drawable-mdpi and drawable-ldpi. Test those in different screens in the emulator and tweak the sizes appropriately
Please read supporting multiple screens.
In a nutshell: It's very easy. You can create subfolders of each folder in the resources (like layout-small, layout-large, layout-hdpi), and add different versions of your layout. The system will always fall back to the layout folder if none of your specializations (hdpi, large, etc) match.

Categories

Resources