Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

android - Fill the dessert in my head with "dimens" [xml]

Hello guys and girls.

As i already asked, is someone here who can give me a hint how to calc the right ammount of dimens?

As far as i know:

  • dimens "small" support devices with a <=3,4 inch screen
  • dimens "normal" from 3,4 to 5,0
  • dimens "large" from 4,5 to 7
  • dimens "xlarge" from 7 to +

these are relative to the physical screensize in inches and NOT the correct numbers. Got it from a graph on this website without labeling: https://developer.android.com/guide/practices/screens_support.html

also there are dimens which depends on the ammount of pixels.

  • ldpi
  • mdpi
  • hdpi
  • xhdpi

Do i really need to have 16 different folders, to prevent that a wrong layout is shown on the device, like; small-ldpi,small-mdpi,small-hdpi,small-xhdpi,normal-ldpi,normal-mdpi,normal-hdpi and so on. If so, do i need to create 16 AVD′s to test each layout? Also, the emulator is not so accurate with displaying the layout as it is on a real device. So do i need to have 3 or 4 physikal devices with the most common screensizes and resolutions.

If i only consider the screensize in inch, is it still possible to have a consistent layout?

The resolution of the Icons: If i want to have the icon in a consistent relation to the layout, how much icons should i create? im thinking about 4 different sizes of each icon( ldpi,mdpi,hdpi and xhdpi) but every icon is in 4 different folders small/normal/large/xlarge.

Thank you for your help, Phil

Quote: Like my IT teacher said, a good programmer doesn′t need to know anything, he only needs to know where to find it. cheers

P.S, im asking cause i don′t like to spend hours and hours in xml if someone can say " listen, 5 folders are enough. 16 folders are 'nice to have' maybe a 6th because of this new 21:9 hype."

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

i was also running with same issue then i used this awesome library a scalable size unit - SDP Intuite

No need to worry on different density device this library will handle it

thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...