Support all android screen size - java

I'm have tired to support all android , but I want to ask about supporting all screen size on android
I have 4 layout folders :
layout
layout-ldpi 2.7 inch = 240*320
layout-mdpi 3.2 = 320*480
layout-hdpi 3.7 = 480*800
layout-xhdpi 800*1280
layout-xxhdpi 5 inch 1080*1920
Is this setting in each layout support all devices or maybe I have missed some thing ?
Note : I have reviewed android site Android Developers many time .

I'm not sure what you want to achieve. You should split your resoures in two groups. One with density (folder called drawable) which contains images in different sizes for different display resolutions. The second one with layout (called layout) is for supporting different UI layout of each screen. Typically for tablet or mobile phones. So you should have forlder
drawable-ldpi, mdpi, etc. - here will be your png files
layout-"default",sw360, sw600, sw720 ("large" mobile, small 7" tablet, large 10" tablet). If your are targeting below 3.2, you can't you sw (smallest-width) but use older small, medium, large, xlarge screen size. - here will be your *.xml layout files
Don't mix up layout and density resource qualifiers together. See more here

Related

Creating Same UI Supporting Different Screen Sizes?

I am Currently having designing problems in android studio.
I want to create UI which should looks same on every device but now i can't do that properly. i am using constraint layout and these are the screenshots :
For Android Screen Size 4.7 UI looks like below screenshot :
and For Android Screen 7.0 Size UI looks like this screenshot :
as the images shows the circular image on screen size 7 is pretty small and edittext is too looking worst.
How can i support both or more screen sizes while keeping the view like screen size 4.7.
Adaptive constraints can be used to achieve this.
For example, instead of putting an image view of say 100 * 100 dp, you can use specify the width in percentage of the screen size.
ConstraintLayout comes with many tools to help you with such as barriers, percentageWidth, chains etc.
A nice blog to get you started on the same : https://proandroiddev.com/getting-your-constraints-right-constraintlayout-786254ed1166
(I am the author of the blog)
Use SDP - a scalable size unit library for supporting different screens.
An android SDK that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.
Here is the LINK
To Support different screen sizes. Use ConstraintLayout. Google has solved the biggest problem for Android developers called Support different screen sizes by ConstraintLayout.
https://developer.android.com/training/multiscreen/screensizes

Background/UI for multiple devices

I’m new to Android programming and I’m stuck with a very specific problem. I want my application to run on multiple screen sizes and densities.
I have several real devices with different screen resolutions (Samsung Galaxy S7 Edge [xxxhdpi], Samsung Galaxy A5(6) [xxhdpi], Samsung Galaxy Note 10.1 tablet [xhdpi].
I made one background and scaled it down for every generalized density. I saved the files as “background.png” in separate folders like suggested in Supporting Multiple Screens.
After testing the APK on the devices, everything worked fine except the background on the S7. It will always load the next lower resolution bitmap (xxhdpi instead of xxxhdpi). I looked countless threads how to fix this problem but nothing worked so far.
The resolutions of my bitmaps are:
drawable-mdpi //320x480
drawable-hdpi //480x800
drawable-xhdpi //720x1280
drawable-xxhdpi //1080X1920
drawable-xxxhdpi //1440X2560
I hope that someone can help me on this one. I’m really losing my mind.
This is a little complex but I'll try to keep it simple. The android system chooses the right resources based on a lot of factors (which you can see when you create a new resource file under the "Available qualifiers" list) which you can group to create a resource shared by different configurations or use only one of them to specify one particular configuration. But you cannot control witch resource the device will use for the most part (there are some you can specify yourself ex: night mode). Your S7 probably uses the wrong resource because probably one of the settings for the display resolution is set at a lower setting (ex: battery saving modes lower resolution, gaming mode.. etc, accessibility settings). And if you want a tablet to use a different drawable then a phone then you should use the "smallest screen width" qualifier since you can specify different screen sizes in Dip(ex: sw320dp is a normal phone, sw440dp is a big pixel phone, sw720dp is a medium tablet and sw1048dp is a bigger tablet). Read more here
I'm also facing like this. My app only works on high resolution mobile only. Then I found that error. I placed my drawable on drawable-hdpi only . For every assets we have to place default drawable in drawable folder
put default drawable in that folder.
drawable
For handling images on the s7 device we can give height and width to the image view. Set the values for height and width from the dimens file. For handling s7 UI need to add the dimens-sw411 file and specify the height and width in that.

Android studio - Different device is using the same layout, but everything looks good only on one of them

I have 4 sets of layout xml and corresponding drawbles, including hdpi, tvdpi, xhdpi, and xxhdpi
I have 2 phones to test the app on, one is a virtual Nexus 5x, another one is a physical Galaxy Note 4
The xml layout works out perfectly on the Nexus 5x, but since (I assume) Note 4 has a smaller resolution / different ratio, the content is overlapping a little bit on it.
This app is very different than regular ones since it has a lot of image views in a relative layout arranged in a specific pattern. Problem is that the system is using xxhdpi resource and layout on both of the device. How do I fix it in a situation like this?
Thanks!
I faced the same problem few days ago.Use dimen.xml which is lacated under values folder.Make folder like values-sw600dp and make dimen.xml under this. Define all the relations in there and call it using #dimen/....
Android automatically will choose best match for your device.

Layout problems on Samsung Galaxy Y S5360

I am new to Android Development. I have recently developed an app that supports Screen sizes of 3" to 4"! The problem is that When I run my app on my HTC Wildfire S (3.2") it works find the screen visuals are fine to see and it gives best resolution.
But when I run the same app on my Samsung Galaxy Y S5360 (3") a small portion of the screen vanishes at the spot I mean the screen visuals are not so much visible to see and gives bad visuals of screen.
Why it is so when I have set the screen size as ranging from 3" to 4". I am using Relative Layout and in the Eclipse IDE the Screen is showing so well also.
HERE is the Eclipse IDE image
HERE is my Samsung Galaxy Y S5360 Image: sorry for poor image.
YOU can see the problem of text at the bottom of cell phone image how can i fix this? please help thanks in advance!
First- never trust the eclipse plugin. Its buggy, and its an estimation anyway. You can use it to see if you're roughly right, but never expect it to look like that ont he actual device, much less on all devices.
As for your problem- the screen on your device is too small for your layout. You either need to cut out whitespace or shrink something. If you can find out the exact resolution of this device you could make a special layout for devices of that resolution.
This is a standard problem in android UI design- you're developing for a lot of screen, some of which are very small. If you want it to work on everything, you have to be very careful with the amount of content and empty space on each screen and test against a variety of resolutions and physical sizes.
A good way to get around this is to size everything in dp. 1dp=1/160th of an inch. Then you know how big a screen you'll show on.
My 2 suggestions are as below
1.Can you try using scroll view for your content
2. apply full screen to your app & change the current layout of the app(if in case of linear layout)

Android screen size and density. How to choose text size?

I'm trying to understand multi-screen support in android. Yes I read the documentation, but still have few questions.
As I understand i need to create drawables for each density, but what to do with text size?
I want to set title on my activity which will fit any screen (need to big big enough and don't warp the text)
I test in on my Nexus7 (large screen) and it looks good with android:textSize="100dp"'
When i launch it on emulator with 'normal screen' size i get very big text.
So is it right solution to make layouts for each screen size?
'layout'
'layout-large'
'layout-small'
....
and just make android:textSize="70dp" for normal screen and android:textSize="50dp" for small screen?
And another one question how to test all this in more efficient way?
I need to create emulators with? Where to get parameters with which create emulators to get this results?
XLarge screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Large screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Medium screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Small screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
For text size you should use sp units. Docs say:
Scale-independent Pixels - This is like the dp unit, but it is also
scaled by the user's font size preference. It is recommend you use
this unit when specifying font sizes, so they will be adjusted for
both the screen density and the user's preference.
As I understand i need to create drawables for each density, but what to do with text size?
As WebnetMobile indicates, you start by using sp, as this takes the user's choice of font scale into account. However, you may need more than that.
So is it right solution to make layouts for each screen size?
I would recommend using dimension resources, with different definitions for the text size dimension as needed for your different scenarios.
Where possible, though, design your UI to be more flexible about font sizes. Again, if you use sp, the user can change the size of the text on Android 4.0+, to make it bigger or smaller, to help them read the text on their device. Hence, you cannot assume that you are in complete control over the size of the font, and therefore need to design accordingly. This is not significantly different than designing a Web site that takes into account users' adjustments to font size in their browser.
And another one question how to test all this in more efficient way? I need to create emulators with?
You will need emulators or devices for whatever scenarios concern you.
Where to get parameters with which create emulators to get this results?
On the (now-current) R21 versions of the tools, you set the screen size and density in the Device Definitions tab of the AVD Manager, then create AVDs based upon those definitions as needed.
Inorder to test in different screens and density you can create emulators with different combinations. When we create the emulator device we can set the Density (Abstracted LCD density under hardware).
ldpi - 120
mdpi - 160
hdpi - 240
xhdpi - 320
You can set the screen size also while start the emulator

Categories

Resources