2

How to handle design in multi screen for mobiles in Android without using dimention in values folder.

My application it's support all android mobiles, and I had a problem with the design, because I'm using dimen in values folder to handle it.

So please anyone can help me to handle this problem without using the dimention.

mehrdad khosravi
  • 2,228
  • 9
  • 29
  • 34
Lana.Manaseer
  • 94
  • 1
  • 5

3 Answers3

13

layout compatibility is very important part of any project

sorry but you have to use dimens for handle this problem. and i think best way for design is use density.

you can use dimens-hdpi or dimens-mdpi or ...

and can use dimens-small or dimens-large or ...

and can use both of them together. like dimens-larg-mdpi

but this is so hard to design.

i using dimens smallest screen width this use density and i think you can handle all of phones or tablets by 4 or 5 dimens.

like this picture.enter image description here

Typical numbers for screen width dp are:

  • 320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480: a tweener tablet like the Streak (480x800 mdpi).
  • 600: a 7” tablet (600x1024).
  • 720: a 10” tablet (720x1280, 800x1280, etc).
  • if you have a device don't support by one of these you can add another smallest screen width for that.

you can read more details here , here , here and this help you know your phone pixels per inch.

example:

you have a phone 1080*1920 pixel and 5" size.

enter image description here

  • first formula help you calculate pixel per inch (dpi).
  • second formula help you calculate Pixel ratio.
  • and last formula help you calculate dp.

this phone have 392 dp in width and smallest width for that is 320.

if you like use dpi Pixel ratio can help you.

  • ldpi => Pixel ratio = 0.75
  • mdpi => Pixel ratio = 1.0
  • hdpi => Pixel ratio = 1.5
  • xhdpi => Pixel ratio = 2
  • xxhdpi => Pixel ratio = 3
  • xxxhdpi => Pixel ratio = 4
Community
  • 1
  • 1
mehrdad khosravi
  • 2,228
  • 9
  • 29
  • 34
  • I think this is the best way and your formula is awesome. I have struggled with properties size and dpi to make my app looks perfect for ALL screens. But I figure it out, I can't with those properties. It just fit on most devices, not all. Only calculating within the smallest width makes it work – Slim_user71169 May 17 '16 at 04:57
  • @mehrdad khosravi can u give me link of any project so that I understand how to use it in my project... please :) – Shivam Sharma Jul 28 '17 at 13:38
2

if you want to support all resolution (ldpi ,mdpi ,hdpi , xhdpi , xxhdpi , xxxhdpi ) then you can put your images those folders. For text sizes its a good practice to use dimension folder. But if you do not want to use dimension folder then you can pick resolution of device programatically and change your text sizes

Wasir
  • 185
  • 2
  • 11
1

mipmap-hdpi, mipmap-mdpi,mipmap-xxhdpi, this folder are you that u need to use them for diffrent resolution

you can read : http://developer.android.com/guide/practices/screens_support.html

Vladimir
  • 28
  • 1
  • 13
  • thanks for your answer. but this folders for drawable files, i need help in the layout and the position of views in the layouts for multi screens – Lana.Manaseer Apr 24 '16 at 08:50