android – Galaxy S和Galaxy S2的最小宽度

前端之家收集整理的这篇文章主要介绍了android – Galaxy S和Galaxy S2的最小宽度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发一个 Android Widget,需要区分Galaxy S和Galaxy S2.
我几乎阅读了有关屏幕尺寸和密度文章的所有内容.
当然,我需要使用新的限定符和新的限定符Smallest Width.
我的问题是,sw320dp限定符匹配Galaxy S和Galaxy S2.
但是我需要Galaxy S2的另一种布局,但是找不到合适的限定符.

银河S的定义,密度233

屏幕尺寸(像素):480像素x 800像素

屏幕尺寸以dp为单位:329dp x 549dp(原因1dp = 1pixel /(密度/ 160)

-> so the qualifier sw320dp must match here. and yes it does

Galaxy S II的定义,密度218

屏幕尺寸(像素):480像素x 800像素

屏幕尺寸以dp为单位:352dp x 587dp(原因1dp = 1pixel /(密度/ 160)

-> so the qualifier sw340dp must match here,but NO it doesnt

(Tested in emulator and on real device)

drawables不是问题,但我的布局,特别是高度和文本大小在这些设备上是不同的,所以我真的需要一个特定的布局.

任何人都有想法或更多的经验吗?

解决方法

屏幕密度,由参考材料定义为:

The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example,a “low” density screen has fewer pixels within a given physical area,compared to a “normal” or “high” density screen.
For simplicity,Android groups all actual screen densities into four generalized densities: low,medium,high,and extra high.

低= 120dpi
med = 160dpi
高= 240dpi
xhi = 320dpi

因此,实际密度为218的Galaxy SII在dp计算中被分配了240的“高”密度.因此,屏幕的宽度为dp为480/240 * 160 = 320.

这很糟糕,我同意.但它是如何运作的.

http://developer.android.com/guide/practices/screens_support.html

原文链接:https://www.f2er.com/android/314698.html

猜你在找的Android相关文章