我刚刚在 android 上发布了我的应用程序,并遇到了高密度显示器客户的问题。
我添加了一个调试东西来看看发生了什么,这是一个示例输出
设备:Nexus 10 Android 版本:4.2.2 DisplayMetrics{density=2.0, width=2560, height=1504, scaledDensity=2.0, xdpi=298.275, ydpi=298.823} MainView w=1900 h=1342 mDrumKitMode=BIG KitView w=640 h=1266 x=1920.0 y=0.0
主视图是屏幕截图左侧的乐谱区域,其 1900 宽(MainView w=1900 h=1342)鼓组是 640w 和 640 高的位图。不知何故,显示器将其缩放为父级的全高(KitView w=640 h=1266 x=1920.0 y=0.0)。这不会发生在密度 = 1.0 的显示器上。
我无法对此进行测试,因为由于某种原因我无法让模拟器在大显示器上工作,而且我没有高密度平板电脑。
有谁知道会发生什么?谢谢
这是另一个有类似问题的客户
设备:A700 Android 版本:4.1.1 DisplayMetrics{density=1.5, width=1920, height=1128, scaledDensity=1.5, xdpi=224.73732, ydpi=224.11765} MainView w=1260 h=1044 mDrumKitMode=BIG KitView w=640 h =968 x=1280.0 y=0.0
我认为它的 scaledDensity=1.5 参数,也许我需要做一些事情来禁用自动图像缩放,即设置 scaledDensity=1?
i should add that the entire application is based on exact pixel positions, both for the music notation display and the drum kit display which overlays images on top of the base drum kit image (you can see the drum pedals are in the wrong place on this image too). i don't want automatic scaling as i handle scaling inside the app for different display sizes and user preferences.
i should also add that all my drum kit images are in drawable-mdpi and all the other dpis are empty. this is because i scale images programmatically based on screen size and user preference BUT i think maybe the problem is a need to put some images in xhdpi? i guess i can do that but it will be a lot of work.
PS, i guess i found my answer here http://developer.android.com/guide/practices/screens_support.html
Provide different bitmap drawables for different screen densities
By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) and Nine-Patch drawables (.9.png files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen. This scaling can cause artifacts in the bitmaps. To ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
i wonder if simply copying all the -mdpi images to -xhdpi will work?