Android 模拟器将 600x1024 MDPI 报告为 XLarge?
我目前正在尝试测试现有应用程序与即将发布的 Amazon Kindle Fire 平板电脑的兼容性。他们说将模拟器设置为 600x1024,将 LCD 密度设置为 169(https://developer.amazon.com/help/faq.html?ref_=pe_132830_21362890#KindleFire 尽管在电子邮件中他们说 160 而不是 169)并且应该报告为“大”并且不是“xlarge”(这是我从与他们的支持团队的来回电子邮件交换中得到的,我抱怨它不起作用)。
当 Google 将此分辨率和 MDPI 列为“大”时,他们在测试多种屏幕尺寸的部分中似乎支持这一点(http://developer.android.com/guide/practices/screens_support.html#testing)。但是,每当我将“layout-xlarge”文件夹与“layout-large”一起包含时,模拟器总是加载“xlarge”。如果我将 LCD 密度更改为 240 之类的值,它会加载“large”而不是“xlarge”,但这不应该是正确的,我担心这意味着它无法在最终设备上工作。为了测试这一点,我采用了“Multi-Res”的 API-10 示例,并创建了一系列上述布局文件夹,每次加载“xlarge”(如果存在),如果不存在“则加载“large”超大”。
所以,我的问题是,我是否正确阅读了文档,或者我的模拟器是否在某种程度上搞砸了,因为亚马逊的人们坚持认为它应该报告为“大”,如果这是真的,它永远不会正确加载“xlarge” ?
以下是我修改以测试此示例的 Multi-Res 清单中的内容:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multires"
android:versionCode="1"
android:versionName="1.0">
<uses-permission
android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name=".MultiRes"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:anyDensity="true"
android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
</manifest>
I am currently trying to test an existing application for compatibility with the soon to be released Amazon Kindle Fire tablet. They say to set the emulator at 600x1024 and LCD Density to 169 (https://developer.amazon.com/help/faq.html?ref_=pe_132830_21362890#KindleFire although in email they said 160 instead of 169) and that it should report out as being "large" and not "xlarge" (this I have from a back and forth email exchange with their support team where I'm complaining it does not work).
Google seems to support this as being true in their section on testing for multiple screen sizes when they list this resolution and MDPI as being "large" (http://developer.android.com/guide/practices/screens_support.html#testing). However, anytime I include a "layout-xlarge" folder along with the "layout-large", the emulator is always loading the "xlarge". If I change the LCD Density to something like 240, it loads "large" instead of "xlarge", but that is not supposed to be correct and I'm worried that means it won't work on the final device. To test this, I took the API-10 sample of "Multi-Res" and created a series of layout folders described above and every time it loaded "xlarge" if it was there and would load "large" if there was not an "xlarge".
So, my question is if I'm reading the documentation correctly or if my emulator is somehow messed up as the folks at Amazon are insisting it should be reporting as "large", which if that were true it would never load "xlarge" right?
Here is what I have in the manifest in the example Multi-Res that I modified to test this:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multires"
android:versionCode="1"
android:versionName="1.0">
<uses-permission
android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name=".MultiRes"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:anyDensity="true"
android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是文档中的一个错误。如果我们查看用于计算屏幕尺寸的实际代码,我们可以看到 160 dpi 的 600x1024 屏幕确实会被视为 xlarge。
别相信我的话。实现位于 WindowManagerService.computeNewConfigurationLocked() ( JavaScript 缓慢的警告)。有趣的部分如下。屏幕尺寸(以像素为单位)根据密度进行缩放:
对于 mdpi (160 dpi) 屏幕,dm.密度将为 1.0。对于 hdpi (240 dpi),该值为 1.5。在我们的例子中,我们有一个 mdpi 屏幕。因此,此代码运行后,
longSize == 1024
和shortSize == 600
。不久之后,我们到达以下代码:其中
longSize
和shortSize
的值意味着mScreenLayout
将被分配Configuration.SCREENLAYOUT_SIZE_XLARGE< /code>,换句话说,屏幕将被视为“xlarge”。有趣的是,如果屏幕短边小一个像素,则只能被视为“大”。
所以,您正在正确地阅读文档,但据我所知,文档是错误的,而您的模拟器则很好。
This seems to be a bug in the documentation. If we look at the actual code that is used to calculate screen size, we can see that a 600x1024 screen at 160 dpi will indeed be considered as xlarge.
Don't take my word for it. The implementation is in WindowManagerService.computeNewConfigurationLocked() (warning for slow JavaScript). The interesting bits are as follows. The screen size in pixels is scaled based on density:
For a an mdpi (160 dpi) screen, dm.density will be 1.0. For hdpi (240 dpi) it will be 1.5. In our case we have an mdpi screen. So after this code has run,
longSize == 1024
andshortSize == 600
. Shortly after, we reach this code:which with our values of
longSize
andshortSize
means thatmScreenLayout
will be assignedConfiguration.SCREENLAYOUT_SIZE_XLARGE
, in other words that the screen will be considered 'xlarge'. It is interesting to note that if the screen was one pixel smaller on the short side, it would only be considered as 'large'.So, you are reading the documentation correctly, but as far as I can see, the documentation is wrong and your emulator is just fine.