changing display size of android app - android

My developed Android app works well on my phone, and I have used linear layout, and set the pixel as dp.
However, there is a setting in my phone, which can change the screen display size, I set it to large, and some of my layout is outside of the screen.
I tried to look up at the official document, but I found that it said usually setting change won't affect.
How can I resolve it?

You can create dimension xml file for different screen density pixels. Refer this link for more details
How to define dimens.xml for every different screen size in android?

Related

Is there a function in Android Studio to automatically adjust the layout to the display size?

I'm in the process of creating a small questionnaire. Although all views are constrained, the individual text views overlap or slide to the edge.
So far I have only created the design for the layout and have not yet linked any functions with anything. When I display the layout on a larger display, everything is shown as it should be.
Can someone help me and tell me how I can design my layout so that it automatically adjusts to the display size?
I'm really new about programming in Android and don't know all the backgrounds I may have disregarded.
I tried to use the AutoSizeMaxText fuction but I'm not sure if I used it the right way.
As far as I know there is no such thing as an automatic function to support different screen sizes.
What you can do:
Use constraintLayout
Use match_parent and wrap_content instead of hard-coded sizes in your xml
Create different layouts for almost every (if not every) screen resolution:
ldpi, mdpi, hdpi, xhdpi, xxhdpi
Use stretchable nine-patch bitmaps for image resources.
Consider using fragments and double-pane structure for large devices
You may want to chek this library: https://github.com/intuit/sdp
and this one for text size: https://github.com/intuit/ssp
Don't forget to test it in as many devices with different resolutions and pixel density as you can.
You can check the official documentation for this issue: Android developers: Support different screen sizes

android system is taking layout xml files only from layout-320

I am developing app.I have only layout folder with xml files,it is showing properly in more pixel screen ,but when i see my app in less pixel screen the text is big not same as more pixel screen As per android developer site, I came across layout-sw320dp ,layout-sw480dp. So I have added the xml files into layout-sw320dp,layout-480dp and made changes like text size and margin,then when i run them with sw-320dp in less pixel screen i can see text size same as more pixel screen,but when i run with sw-320dp the same in more pixel screen, the text is small ,it is taking layout from only sw320 actually it should take from layout folder.I d'not know where I am wrong can any one tell me.
screens with only layout folder
[![screen in less pixel density[![screen with more pixel][1]][1]][2]
screens with layout-sw320sp
[![screen in less pixel [![screen with more pixel density][3]][3]density][4]][4]
[1]: http://i.stack.imgur.com/6rTNw.png
[2]: http://i.stack.imgur.com/uHRkx.png
[3]: http://i.stack.imgur.com/qhcmk.png
[4]: http://i.stack.imgur.com/Z5PE0.png
You are not supposed to pick what resource size is shown, android does that depending on the device used at runtime. Your job is to set the resource in the correct folder for example res/layout/mylayout.xml and res/layout-sw480dp/mylayout.xml res/layout-sw320dp/mylayout.xml sw is smallest width of screen, 320 is a number, dp can be thought of as pixels. This concept of putting resources in folders with special names and allowing android to pick the most sutable special name/folder for the job works for any resource. Strings/languages, images/for device screen size,night/day,orientation-|.

Android font size in pt

I'm working on a Android project where I need to build my layouts based on a JSON layout file. This same file is also being used on an iOS app. So there is 1 file which will render the same layout on the Android as well as on the iOS.
The JSON layout file defines its font sizes based on the default iOS font unit.
From the Android docs:
Points - 1/72 of an inch based on the physical size of the screen.
And as far as I can find, iOS font sizes are also defined as 1/72 of an inch.
So based on this info, I'd say the following should be enough:
view.setTextSize(TypedValue.COMPLEX_UNIT_PT, fontSizeInIosUnit)
This however results in the text being too large. And it also seems to differ per device (which is weird since points should always appear in the same physical size).
If you want fonts to resize properly according to screen size you should use dp/dip instead.
So try this instead:
view.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeInIosUnit);
Now this might not be exacly the same but in my experience this gives the best results. If it doesn't have the proper size then figure out what size you need on Android as the base size and then go with that instead.

Layout Alignment Issues For Device to Device

When I try to run my project on LG Android Mobile then there is no alignment issues come with this device it is a 3.2 HVGA but when I try to run it on Motorola it is a 3.7 WVGA then it gives complete layout alignment issues so can you tell me suggestion to implement layouts uniquely to every device.
I don't know is it possible or not to make a unique layout design for all devices.
You can't create custom layouts for different devices, but you can for different screen densities and sizes, Supporting Multiple Screens has all of the information you should need.
You can create custom layouts by reading the device layout screen like this
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
There are two ways you can create your layout. You can create your own algorithm that checks the difference between the resolution you have made your layout for, and gets the difference for the current screen size, and adjust all those values progmatically (long and tedious, but DEFINETELY will work on all devices)
Or, you can define a layout for each of the common devices in your layout folder. This requires alot more space and time though.
Sometimes back I was having this type of problem. Because I was using Pixels as my unit to specify height, width or any layout specific dimensions. But I changed those px to dp and it worked for me. I got same layout for all the screens. Hope if this may help you anyways...
Here is a quick checklist about how you can ensure that your application displays properly on different screens:
1.Use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file
2.Do not use hard coded pixel values in your application code
3.Do not use AbsoluteLayout (it's deprecated)
4.Supply alternative bitmap drawables for different screen densities

Image Sizes and Android

I'm trying to create a splash screen of sorts for my Android App but am having problems getting the image to fill the screen (too tall, too skinny, etc). Instead of messing around recreating the image a million times to find the correct dimensions I was wondering if there is a "standard image size" that I should use for each screen density if I want it to properly fill the entire screen?
I would make the image stretchable using draw-9-patch. You will probably still need a few different image sizes but this way your images should be able to stretch without getting distorted for screen sizes you aren't expecting.
Yeah the Android docs has all of this relevant information in the: Supporting Multiple Screens section. There is a table in there that should specify all of the different screen sizes that you will need to account for.

Categories

Resources