Supporting multiple screen sizes, some things look too small - android

I am almost done my app, but when I did a test run on an xlarge screen, something odd happened. All the EditText fields, the text in all the buttons, and even the Toasts all appear much smaller relative to the size of the screen. It's almost as if they are the size they would be on a normal screen, but for some reason the app didn't scale them up to a larger size to fit the screen. My EditText fields are larger because they are using weights to specify a height, but the text you type in them is miniscule on the larger screens.
I was surprised that even the Toasts didn't scale up, aren't they an internal thing to the Android system?
I searched around, and found that I should include this in my manifest:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
I have it above my application tag and below my users-sdk tag, but still not luck.
Any idea about what's going on?
EDIT: I use dp units for everything. Toasts I create programatically though, the usual way. They look great on normal screens.

Check your custom or overridden styles if you have any, they may be affecting your Toast size. Otherwise may create your own Toast subclass:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView
Here you can find the default Toast layout, as you can see it uses #style/TextAppearance.Small which is a built-in user customizable style:
how can I find the layout parameters of the toast widget?

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

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.

how can i get my android app to properly display on a touchpad?

i created a game and released it, but really only tested it on phones and the emulator. later on i downloaded it on a touchpad and it confined to a small box at the top. through some searching i found that adding this code to my manifest:
android:resizeable="true"
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="false" />
i got it to fill up the whole screen, but everything is now horrendously out of proportion. is there a better way of going about this? do i need a separate layout xml for phones and touchpads? do i need to rewrite my original xml from the ground up?
Read this article:
http://developer.android.com/guide/practices/screens_support.html
By following the practices described in this document, you can create
an application that displays properly and provides an optimized user
experience on all supported screen configurations, using a single .apk
file.
...
Your application achieves "density independence" when it preserves
the physical size (from the user's point of view) of user interface
elements when displayed on screens with different densities.
Maintaining density independence is important because, without it, a
UI element (such as a button) appears physically larger on a low density
screen and smaller on a high density screen. Such density-related size
changes can cause problems in your application layout and usability.
...
The Android system helps your application achieve density independence
in two ways:
The system scales dp units as appropriate for the current screen density
The system scales drawable resources to the appropriate size, based on
the current screen density, if necessary
I think it is better to design your layout for every screen size and resolutions. It is easy in android. Copy your layout from "layout" folder of resources and paste it in the "layout-land", "layout-xlarge", "layout-xlarge-land" and ... folders and change those settings you need in them.
you can check this link:

Android Application not fit to screen correctly

I have found a problem in Android Emulator,
when i run application on Emulator on android 2.3.3 WQVGA400 it runs fine,
but screen width size is so small
so i check the Built in Resolution to make width size to 800" something and height t0 600"
Now my problem is when i run application on this, then it shows only in a short portion of Emulator screen, extra space on below is always remain
And one thing is that when I run on Actual device is runs very perfectly
You should probably read this: http://developer.android.com/guide/practices/screens_support.html
Add to your AndroidManifest.xml
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
How do you add the text in the green buttons? Is this button a nine patch image? Is the text separate from the image?
Use nine patch images. Then add the text using Button control, where you put the image as background and the text as caption/title/text so on. And when you run the application on larger screen, the image + text will be resized correctly.
Add next line to your AndroidManifest.xml:
<supports-screens android:resizeable="true" />
More information about this attribute can be found in documentation.

Categories

Resources