Guidelines to support multiscreen android layout - android

I am currently working on an Android app. I am not an UI guy, and just trying out which number fits the best when I make the layout xmls like below:
<ImageView
android:id="#+id/my_icon"
android:layout_height = "30dp"
android:layout_width = "wrap_content"
android:layout_gravity = "center_vertical"
android:scaleType="centerCrop"
/>
I know that 30dp will work ok on xxhdpi devices because that is what I am using and testing, but I think this will cause trouble when the screen resolution is lower (say, a mhdpi device).
I am wondering if there is any guideline on how to make a layout support different res?

You can find giudelines in following links
How to support different screen size in android
http://developer.android.com/training/multiscreen/screensizes.html
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/training/basics/supporting-devices/screens.html

Here you can find some guidelines:
http://developer.android.com/design/style/devices-displays.html

For Different screen size, 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 small, medium, high, and extra high density screens.
res/layout/layout.xml
res/layout-small/layout.xml
res/layout-large/layout.xml
res/layout-xlarge/layout.xml
res/layout-xlarge-land/layout.xml
res/drawable-mdpi/icon.png
res/drawable-hdpi/icon.png
res/drawable-xhdpi/icon.png
The following code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />

Related

How to support multiple screen sizes in android

I am having a problem displaying my layout in 5" or smaller screens .The smaller height of phone spills bottom views out display . I tried creating layouts using sw320dp and different dimens folder but app seems to take that smallest layout only for all type of sizes. I am unable to map the layouts properly . All I need is to make the size of views smaller in small screens.
-You should use ConstraintLayout for Create a flexible layout
-You should use Different dpi icon for different phones like mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi
-you can also take reference from Google's Documentation
https://developer.android.com/training/multiscreen/screensizes
Add this code in your Android Manifest xml
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
Try this library it will be helpful
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
This library will help to create flexible view items as per device screen sizes.
You can use constraint layout, it will effectively adjust most of your views. Along with that, as a precaution, add scrollview in layouts where you think you have too many views just so they don't go out of screen bounds on smaller screen sizes.
Constraint layout doc: https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout

Android single screen layout for all devices

I created an Android app and tested it on Nexus6 Emulator. Everything seems fine on Nexus6 Emulator but when I ran that app on real devices (Samsung S6 and S5) the layout was all messed up. How can I fix this?
Do I have to create separate layout for each device?
Does Android have something like 1 layout for all screens?
I dragged and dropped all images in drawable folder instead of using "add image asset". There is nothing in hdpi, mdpi folder. All images are in drawable folder. Is this the cause of my issues?
Please advise.
It is all about the design of your xml. When designing your pages, try to use 'match parent' and ensure that you are making a layout that fits across all screen resolution. Look into AFAIK...
https://developer.android.com/training/multiscreen/screensizes.html
https://developer.android.com/training/multiscreen/screendensities.html
https://developer.android.com/guide/practices/screens_support.html
How to define dimens.xml for every different screen size in android?
For example:
In your xml
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />

setting correct size for android screen

Pleas can some one help me understand what values I should use to fit most android screen sizes.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.airrocketapps.macuser.airrocketapps">
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
android:requiresSmallestWidthDp="320dp"
android:compatibleWidthLimitDp="320dp"
android:largestWidthLimitDp="320dp"/>
<application
Please have look at this article Android Layouts for different Screens
you have to made layout for every screen sizes if you want to handle all types of screen i,e landscape,potrait etc. You must use wrap_content or match_parent for views to fit into present screen or activity.
If you don't specify it will "support", as in launch on, any device with which the rest of the config is compatible. You can remove the support-screens tag completely. But there's a big difference between your layouts _fitting) on screen and them being appropriately designed for those screens.
Checkout Supporting Multiple Screens, Supporting Different Screen Sizes, and Designing for Multiple Screens in the Android docs.

Android application for Tablet

I have developed an application that is to be run on android Tablet as well. It is working on android phones perfectly. When I ran it on Tablet, it did not expand on whole screen. It just covered a area equal to a mobile device. I want that it also runs on Tablet and cover the whole screen as running on mobile device. Do I have to create two different designs for each type and at run time before using design, I would have to check it whether it is android phone or table?
Add below code in android manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Add the following block of code in your manifest file after the <uses-sdk>tag:
<supports-screens
android:xlargeScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Note: Add the android:xlargeScreens="true" attribute if and only if your minSdkVersion is equal to or more than 9.
In addition to adding this block of code, follow this link. Also suggest you to go through the following links:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Densities
Hope this helps.
please try
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="11"/>
<supports-screens android:anyDensity="true" />
in Manifest.xml before tag.
I hope it may be help you.
Yes, ideally you'll design layouts targeted to tablets. You don't have to, but you can. See here for details. Your app is running in "screen compatibility mode". See here for info about that.
I think you used fixed width and height for any view or layout in your app, to support a fixed resolution of your mobile device.
If you use fill_parent, wrap_content and weight property, such things in your app, the app will fill entire screen of any android device. Once review your code.
Small example
Assume device has no rotation. Your device has resolution 320 X 240. you have to fill 3 buttons horizontally, you can put each button width=100 and remaining as margin/padding of layout. If you run same app on device with resolution 640 X 480, some space will come after 3 buttons. If you use width=fill_parent and layout_weight=1 for these 3 buttons and parent's layout_width=fill_parent, on any resolution these 3 buttons will fill the entire width of screen.
I hope it may help you.

Scaling on android devices beyond 480x800

I have a small Android app which works fine on resolutions up to WVGA (480x800), however beyond this the layouts don't scale (for instance for the Galaxy TAB 1024x600) but appear in the top in the middle (with black borders down sides and at bottom). The layouts look fine in Eclipse at these resolutions.
What Am I doing wrong?
Am I missing something in the manifest? Do I need to supply high resolution resources?
Try putting this in your manifest.
<supports-screens android:xlargeScreens="true" />
http://developer.android.com/guide/topics/manifest/supports-screens-element.html#xlarge
putting
<uses-sdk android:minSdkVersion="4" />
In the correct place in my manifest solved the issue. For some reason I had placed it under <application>.
I've created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units is not enough if you want your app to fit on all devices and tablets, since there's 4 different "density-buckets". The tool will allow your layouts to be converted into fitting these density buckets.
It will also explain in further detail how to make flexible view components.

Categories

Resources