Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何以编程方式了解7英寸和10英寸平板电脑,而无需计算屏幕尺寸_Android - Fatal编程技术网

Android 如何以编程方式了解7英寸和10英寸平板电脑,而无需计算屏幕尺寸

Android 如何以编程方式了解7英寸和10英寸平板电脑,而无需计算屏幕尺寸,android,Android,我想知道哪个平板电脑上的应用程序在运行时运行,没有屏幕计算。同样,我们为不同尺寸的平板电脑的图像资源制作了一个可绘制文件夹(例如7英寸的可绘制-sw600dp和10英寸的可绘制-sw720dp)。使用此逻辑将这些值放入如下相应的文件夹中 values-sw600dp//for seven inch <bool name="isSmallerTablet">true</bool> values-sw720dp//for other tablets. <bool

我想知道哪个平板电脑上的应用程序在运行时运行,没有屏幕计算。同样,我们为不同尺寸的平板电脑的图像资源制作了一个可绘制文件夹(例如7英寸的可绘制-sw600dp和10英寸的可绘制-sw720dp)。

使用此逻辑将这些值放入如下相应的文件夹中

values-sw600dp//for seven inch

<bool name="isSmallerTablet">true</bool>

values-sw720dp//for other tablets.

<bool name="isSmallerTablet">false</bool>

让平台为您做检测

创建一个文件res/values-sw600dp/screensize.xml,并将整数值7放入该文件中

<resources>
    <integer name="size">7</integer>
</resources>

7.
创建一个文件res/values-sw720dp/screensize.xml,并将整数值10放入该文件

<resources>
    <integer name="size">10</integer>
</resources>

10

现在在运行时,只需检查值
R.integer.size
即可获得您的尺寸。

据我所知,它取决于屏幕上的宽度大小720属于10''平板电脑,600属于7''平板电脑

有关更多信息,请参阅此处


这是更优雅的方式!
<resources>
    <integer name="size">10</integer>
</resources>