How to set dimensions for different Screens in Android development - android

I am new to the Android development environment.
I would like to have my app designed for multiple phone screen sizes and resolutions.
If the design for all the screens remain the same, will I be able to use one XML layout for the design with the dimensions specified in "dp" and "sp".
Will android automatically scale the dimensions and font sizes for each phones(ldpi, mdpi, hdpi, xdpi, xxdpi, xxxdpi) automatically? Or do I have to create separate layout files for each of them with the respective dp/sp values?
Also, I hope if I put images for each dip in their respective folders, android would pick it up by itself.

Create layouts for screens like this:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra-large in landscape orientation
res/drawable-mdpi/graphic.png // bitmap for medium-density
res/drawable-hdpi/graphic.png // bitmap for high-density
res/drawable-xhdpi/graphic.png // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png // bitmap for extra-extra-high-density

Related

How to add different Images for Splashscreen

How can I add images of different dimensions for Splash Screen?
I have watched some tutorials concerning this, but they always use a single image. I believe there ought to be several images to fit different screen sizes and density. How do I go about adding these images?
You need to use configuration qualifiers on your resource folders to indicate when they should be used. You can simply add the folder to the file structure, or use Android Studio's wizard ( New -> Android resource directory ).
These qualifiers can specify size, density, orientation, aspect ratio, etc. For example:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra-large in landscape orientation
res/drawable-mdpi/graphic.png // bitmap for medium-density
res/drawable-hdpi/graphic.png // bitmap for high-density
res/drawable-xhdpi/graphic.png // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png // bitmap for extra-extra-high-density
res/mipmap-mdpi/my_icon.png // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png // launcher icon for extra-extra-extra-high-density
You can read more about Supporting Multiple Screens from the documentation.

Displaying views according to screen size

When you are displaying views according to dp scale, it means that they are displayed the same physical size at any device... Which means that the display might seem a little emptier at bigger screens right?
Then How do you display views according to the screen sizes?
For different screen size, Use different Layout and different image
This linke is good Supporting Multiple Screens | Android Developers
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density

application layout not supporting with smaller screen size tablet

I have created an application for 10" tablet and set the layout related to screen size but my application is not supported with 7" tablet though i design folder in resource as
res/layout-w320dp
res/layout-w600dp
res/layout-w720dp
so please tell me how to set with other screen sizes.
The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
For further reference check here: http://developer.android.com/guide/practices/screens_support.html

layout for multiple DPI and SIZE screens in android

how am i refer a layout in res library for differnt screens (DPI and SIZE)?
can i do this in re folder:
layout-mdpi-xlarge
layout-mdpi-normal
layout-xhdpi-large
and so on...
http://developer.android.com/guide/practices/screens_support.html
You can find an answer to your question by going through the link in detail.
See the topic under Using configuration qualifiers especially the section under table1.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
For drawables.
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density

Multiple screen support do we need different layouts for each screen

For Multiple screen support do we need different layouts for each screen which goes in hdpi, ldpi and mdpi folders, I read this on android site, but not sure how to implement this one.
Thanks
Max
The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
This information are already given at Android developer site: http://developer.android.com/guide/practices/screens_support.html
Alternative drawables => Screen densities:
Screen resolution (screen density) does affect the appearance of components. To support different screen densities, similarly to the solution given by Ash, have the following folders:
res/values-ldpi for low-density (ldpi) screens (~120dpi)
res/values-mdpi for medium-density (mdpi) screens (~160dpi)
res/values-hdpi for high-density (hdpi) screens (~240dpi)
res/values-xhdpi for extra high-density (xhdpi) screens (~320dpi)
res/values-nodpi for all
Let's assume that you have a default, good-looking layout in the layout folder. In most cases, Android will be able to adjust it properly. In my practice, only large screens require a new layout parameters.
To avoid layout duplication, we use the following layout structure:
res/layout/foo.xml -- layout file
res/values/foo_styles_default.xml -- default styles (component sizes, margins, etc.)
res/values-large/foo_styles_large.xml -- styles for large screen
res/values-xlarge/foo_styles_xlarge.xml -- styles for very large screen
Screen-size-dependent parameters in the 'foo.xml' layout are set via the 'style' attribute, thus allowing us to avoid creating multiple layout files.
As per my observation most of screen will work for different screen size. Please test for app in different screen sizes and if you find issue than place layout in specific folder as diffined above.

Categories

Resources