大屏幕-在多屏幕Android中正常
通过as,有4种类型的屏幕:大屏幕-在多屏幕Android中正常,android,screen,multiscreen,Android,Screen,Multiscreen,通过as,有4种类型的屏幕: xhdpi hdpi mdpi ldpi 我想知道这些屏幕的确切尺寸(像素): normal-xhdpi large-xhdpi normal-hdpi large-hdpi normal-mdpi large-mdpi Eclipse给出了这些屏幕大小: xhdpi : 768 x 1280 2560 x
xhdpi
hdpi
mdpi
ldpi
我想知道这些屏幕的确切尺寸(像素):
normal-xhdpi large-xhdpi
normal-hdpi large-hdpi
normal-mdpi large-mdpi
Eclipse给出了这些屏幕大小:
xhdpi : 768 x 1280
2560 x 1600
720 x 1280
hdpi : 480 x 800
480 x 854
mdpi : 1280 x 800
1024 x 600
480 x 854
480 x 800
320 x 480
这个公式适用于我获得屏幕大小并将其转换为像素:
float scale = getBaseContext().getResources().getDisplayMetrics().density;
int pixels = (int) (120 * scale + 0.5f);
看你在混合这些概念。小、中、大和xlarge是屏幕尺寸,而ldpi、mdpi、hdpi、xhdpi、nodpi和tvdpi是屏幕密度 据 大小
small - Resources for small size screens.
normal - Resources for normal size screens. (This is the baseline size.)
large - Resources for large size screens.
xlarge - Resources for extra large size screens.
密度
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi).
(This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi Resources for all densities. These are density-independent resources.
The system does not scale resources tagged with this qualifier,
regardless of the current screen's density.
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately
213dpi. This is not considered a "primary" density group. It is mostly
intended for televisions and most apps shouldn't need it—providing mdpi and
hdpi resources is sufficient for most apps and the system will scale them as
appropriate. If you find it necessary to provide tvdpi resources,
you should size them at a factor of 1.33*mdpi.
For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
现在,每个尺寸的最小分辨率定义如下
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
同样来自android文档
dp单位到屏幕像素的转换很简单:像素=dps*(密度/160)。例如,在240 dpi屏幕上,1 dp等于1.5个物理像素。强烈建议使用dp单元定义应用程序的UI,以确保在不同屏幕上正确显示UI
这意味着具有不同密度的两个不同设备可以具有相同数量的dp,但像素不同。我想知道的是:普通xhpdi是720x1280,大型xhdpi是768x1280,等等。。。不管怎样,谢谢你给出你的代码。只要把你的dp变量放在刻度里,用上面的公式…你就会得到答案…我已经提供了清晰的答案。试试看,让我知道