Android app UI issue with different screen sizes and resolutions - android

it's my first time to develop for Android and I almost finished the app but when I started testing it I faced some problems related to UI. I tested the app while programming it using galaxy s6 edge plus which has a 5.7" 1440x2560 screen, the app has many textviews and I used "sp" units for their text sizes and also used "dp" units for the margins between them. For some textviews I set their backgrounds as a drawable xml in which I set a value for their width and height using "dp" units instead of using wrap_content because I want the backgrounds to be larger than the text inside it so the user can easily touch it. I also made a large-layout folder where I put new xmls inside it with larger fonts so that they work will on tablet and they did, I tested the app on a tablet and it looks great using these xmls and also the app looks great on the 5.7" phone with the normal textviews. Then I tested it on 2 phones with smaller screens each of 5" one of them with Full HD resolution and the other with HD resolution and it looked good on both of them too but when I tested it on a phone with 5" screen but low resolution (480x800) the app looked terrible, textviews interfering with each other and the drawable backgrounds are too big, in short the whole UI is a mess.
What I need to know is whether I also have to test the app for more screen sizes below 5" or for other resolutions too? Because if this is the case then this means so much work!
This is a screenshot of the code for the textview with the drawable background
Thanks in advance

Go through this tutorial: http://developer.android.com/training/basics/supporting-devices/screens.html and this too: http://developer.android.com/training/multiscreen/index.html
I'm sure this will help you out.
If you still encounter any problem, feel free to ask again!
Peace.

Related

Trouble with implementing app for different screens on Android

I am about to publish my first app and I am extremely confused about making it look nice on different screens.
At first I thought mdpi/hdpi/etc. values (dimensions) folders would suffice when I saw that the screen was showing the exact same things on S4 Mini & S6 Edge, hdpi & xxxdpi respectively.
Well, how is this even possible when I haven't specified other than the main dimensions.xml file?
From what I understand from playing with the layout editor on different devices is that screen size matters more (?).
So far I have created a mdpi/hdpi/xhdpi/xxhdpi folder but it seems that that's far from enough.
What other folders should I make? Do I need many layout folders too?
I would use this scalable size unit library. It's really easy to use and it will automatically scale your widgets for various screen sizes.
Here's the link if you are interested: https://github.com/intuit/sdp

Different Designs and Different screen sizes and Densities

I have read an much more documents on android and other blogs about how to support multiple screen sizes. And To some extent I am successful in making some good looking designs for apps. Now let me start from the start what is the problem and what I wanted to ask from you guys.
Android has now different screen sizes of different screen densities and having different resolutions. so We have to face 3 different things the size , density and the resolution.
Now Let take example of Samsung s4(xxhdpi device having 1080*1920px) , Samsung Grand (hdpi 480*800px) and both has same screen size that is 5 inch
and Samsung galaxy note 10.1 (Mdpi devices ) 10 inch screen size.
Now android says to make different drawable and put them into respective folder, its ok, let suppose its done. Now what ?
lets suppose , What if I have to set the image in left top with the marginleft of 5 dp and some other views according to them with different specific paddings and margins in dps and suppose I have set all of these in my layout according to hdpi device, which we know is not going to look good in samsung s4 xxhdpi device and tablet.
and Also as design pattern says to change design for the tablets according to your need , but on the other hand the support of making different layout has been deprecated now we have to use different values folder.
so in short what is a best way and what is clear thing for making drawables.
how should we re size our drawables to support all devices , and also if making different layout has been deprecated now what should we do to make our design look good and approximately same in all devices?
also how to judge that device is tablet and we should now start showing the multi pane design ?
please do not refer me to android developer website , I know its very helping and I learnt a lot from there , but right now I just want to discuss the technical issues and want to take advantage of some experienced developers. Thanks

Not fiting real resolution

I'm working with a board wich has android 2.3 as base SO. This board has connected an 7" screen and I¡m using this set to develop an app.
While developing this app on eclipse, I'm using RelativeLayouts. This app will only be for an especific screen size, so for the moment I don have the need to use diferent resolutions to fit other screen sizes.
The problem that I'm getting is that I have developed all this program using on eclipse a 7" screen base, but when runing the app on the board, the layout doesn't fit the screen. It makes the same effect as if you create a layout fitting a 7" screen with RelativeLayouts, and then you change this resolution to 5.4". The layout gets oversized and doesn't fit well the screen.
So, what would be the problem? As i said, the screen is 7" and I'm developing for 7". I don't know why happens this.
Its simple, the pixel density of your board is different from the pixel density of your emulator (on eclipse).
I am assuming you did not set a "fixed" size on your images and layouts, only selecting match_parent for width and height, right?
What is happening is that android is scaling (or not) its resources based on your screen pixel density, and that gives you the difference between the emulator and the board.
Screen size does not means equal screen pixel density, and that can cause you a lot of trouble if you do not manage this correctly providing different resources and qualifiers.

How Android manages screen?

I'm just curious look at here
Galaxy Note falls under normal size and XHDPI
Sony Xperia S falls under normal size and XHDPI
But how come in real device the layout look different on each device? How I provide layout for each Android device out there?
I don't think you can ever make a layout that will suit every Android device. I find the best results are by:
(1) Using RelativeLayouts
(2) Avoiding use of any hardcoded dimensions, instead using wrap_content and fill_parent where possible
I build three main layouts: normal, small and large, and I use as many as five sets of graphics for different screen densities and sizes.
It's a challenge!

Large screens layout not as expected

I developed and application and uploaded all the images in the respective drawable folders (different pixels for different desnities).
Now I am confused when it comes to layout. If I used the layout editor with 4.1 inc (thats considered Med screen I guess?) everything looks great.
Now when I use the editor with 10.1 inch which is the tablet, then I see icons very small and the text is small. I have not run the emulator yet.
So I am wondering:
1- why would the text be small although I didn't specify text size? Shouldnt scalle appropriately? or should I give it a specific size for bigger layouts?
2- Why the icons are small given that I provided the different drawables? I thought it would scale up accordingly.
Please don't give me the supporting multiple screens link in android as an answer, as I already went through it and still no luck with above. I need your personal advice as I think I am missing something here
Thank you so much in advance
Android support for different screens is a little tricky. That's because you can have large, small, medium and xlarge screens, plus high, medium and low density ones. There are a dozen possibilities (xlarge low density, small high density) and not a single resolution is defined. So you must know the principles which the API is designed upon and must define your layout thinking about the role the widget has inside your UI. You also must bear in mind that your layout won't be pixel perfect on 100% of devices, so your aim should be being usable on all possible devices.
In your specific case it seems that either you don't manage to specify the correct resources, or the system doesn't pick up the right ones for you, but I must remark that it doesn't make sense on Android to talk about big, small and scale: you should design your layout with a (good) webdeveloper mindset, who daily deals with tons of different displays, resolutions, physical sizes and even devices.
I also suggest not using the graphical builder if you are new to Android, because you really need to know how Android lays out components, otherwise you will come back to SO very often :)
If you do not specify the text size in your layout file Android will take the default value, which is most likely in DIP (density independent pixel) therefore it will be the same physical size on any devices. That should explain why the text looks so small on your 10 inch tablet.
What I would do in this case is have 3 layouts for each activities and specify the text size for larger devices (given you already like the look on phones) and put them in this folder scheme :
res/layout/layout.xml // phones
res/layout-sw600dp/layout.xml // 7” tablets
res/layout-sw720dp/layout.xml // 10” tablets
Information above was taken in this article. I have this applied in my current personal project and so far it works like a charm.
Secondly, as far as icons go, I'm no drawable expert but if you provided the same file in each folder (like I think you did from what I understand in your question), it will not make it scale. You'll have to create 4 difference icons, one for each possible pixel density.
Information about icon sizes can be found on this page.
Hope this is of some help to you.
My experience with the Android device zoo drew me to the sad conclusion that the built-in screen size/layout facility is useless. Cases in point, straight from support:
a 10 inch tablet with Android 2.2. Screen size xlarge is not supported by Android 2.2
Kindle Fire, which is 7 inch and claims it's xlarge.
I ended up putting all three layouts (med/large/xlarge) into layout, loading one based on run-time density and resolution, and providing an option for user to force a specific layout.
Just sayin'.

Categories

Resources