如何确定Android设备的最小宽度 [英] How to determine smallest width of android device
问题描述
我是与不同屏幕尺寸相关联的android布局概念的新手.我希望为8的标签页制作不同的布局,并将其放置在"layout-swxxxx"文件夹中.对于大于8"的标签页,请在"layout"文件夹中使用另一种通用布局.
I am new to the concepts of android layouts associated with different screen sizes. I wish to make a different layout for a tab which is of 8" and place it in a "layout-swxxxx" folder. And have another generic layout for tabs bigger than than 8" in "layout" folder.
这是我的8英寸平板电脑的配置.屏幕尺寸8.0英寸分辨率1200 x 1920像素(〜283 ppi像素密度)
Here is the configuration of my 8" tablet. Screen size 8.0 inches Resolution 1200 x 1920 pixels (~283 ppi pixel density)
谁能告诉我如何计算"sw",以便我可以相应地命名布局文件夹.
Can anyone tell me how to calculate the "sw", so that i can name my layout folder accordingly.
我也没有物理设备,因此我不可能用任何代码来找到该值.因此,请请求其他方法.
Also I don't have the physical device with me so its not possible for me to find this value with any code. So request an alternative method.
谢谢.
推荐答案
链接dp,像素和密度的公式如下:
The formula linking dp, pixels and density is as follow :
px = dp *(dpi/160)
px = dp * (dpi / 160)
因此,就您而言,
widthInDp = widthInPx / (dpi / 160)
widthInDp = 1200 / (283 / 160)
widthInDp = ~678dp
因此,您将要使用sw600dp之类的存储桶
So you're gonna want to use a bucket such as sw600dp
参考文献: http://developer.android.com/guide/practices/screens_support.html
这篇关于如何确定Android设备的最小宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!