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

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...