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
686 views
in Technique[技术] by (71.8m points)

graphics - Difference between "screen size" and "screen density" in Android?

I have a few questions:

  1. What is the screen size?

  2. What is the screen density?

  3. What is a difference between screen size and screen density?

  4. How I can support different densities and different screen sizes in Android?

I have already read the official documentation, but I was unable to understand the difference between screen size and screen density.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)
  • Screen density means how many pixels appear within a constant area of the display, dots per inch = dpi
  • Screen size means amount of physical space available for displaying an interface, screen's diagonal, inch
  • Screen resolution means number of pixels available in the display, scale-independent pixel = sp
  • density-independent pixel = virtual pixel that is independent of the screen density, dp

Density Classes:

Density Class

Icon Sizes:

Icon Sizes

  • (1) Google documentation says: "Applications should not generally worry about this density; relying on XHIGH graphics being scaled up to it should be sufficient for almost all cases."
  • Launcher icons for Android Market: 512x512 px.

Screen Size Classes:

Screen Size Classes

Screen Configuration:

Screen Configuration

  • (1) To emulate this configuration, specify a custom density of 160 when creating an Android Virtual Device that uses a WVGA800 or WVGA854 skin.
  • (2) To emulate this configuration, specify a custom density of 120 when creating an Android Virtual Device that uses a WVGA800 or WVGA854 skin.
  • (3) This skin is available with the Android 3.0 platform.

Best Practices:

  • Use wrap_content, match_parent, or dp units when specifying dimensions in an XML layout file. Except for defining text sizes: sp (scaling depends on user setting)

  • Do not use hard coded pixel values in your application code.

  • Do not use AbsoluteLayout,use Relative Layout.

  • Supply alternative bitmap drawables for different screen densities.

  • Provide a launcher icon for xxhdpi, but no other icons.


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

...