“屏幕尺寸"之间的差异和“屏幕密度"在安卓中? [英] Difference between "screen size" and "screen density" in Android?
问题描述
我有几个问题:
什么是屏幕尺寸?
什么是屏幕密度?
屏幕尺寸和屏幕密度之间的区别是什么?
我如何在 Android 中支持不同的密度和不同的屏幕尺寸?
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.
推荐答案
- 屏幕密度是指在显示器的恒定区域内出现的像素数,每英寸点数 = dpi
- 屏幕尺寸是指可用于显示界面的物理空间量、屏幕对角线、英寸
- 屏幕分辨率是指显示器中可用的像素数,与比例无关的像素 = sp
- 密度无关像素 = 与屏幕密度无关的虚拟像素,dp
- 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
- (1) Google 文档说:应用程序通常不应该担心这种密度;依赖 XHIGH 图形放大到它应该足以满足几乎所有情况."
- Android 电子市场的启动器图标:512x512 像素.
- (1) 要模拟此配置,请在创建使用 WVGA800 或 WVGA854 外观的 Android 虚拟设备时指定自定义密度 160.
- (2) 要模拟此配置,请在创建使用 WVGA800 或 WVGA854 外观的 Android 虚拟设备时指定自定义密度 120.
- (3) 此皮肤适用于 Android 3.0 平台.
在 XML 布局文件中指定尺寸时使用 wrap_content、match_parent 或
dp
单位.除了定义文本大小:sp
(缩放取决于用户设置)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.
为 xxhdpi 提供一个启动器图标,但不要提供其他图标.
Provide a launcher icon for xxhdpi, but no other icons.
这篇关于“屏幕尺寸"之间的差异和“屏幕密度"在安卓中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!