简体   繁体   English

在Android中编程各种屏幕尺寸

[英]Programming For Various Screen Sizes in Android

I'm using the Canvas and the SurfaceView. 我正在使用Canvas和SurfaceView。 I've explicitly mentioned the coordinates for various objects and fonts on the screen. 我已经在屏幕上明确提到了各种对象和字体的坐标。 The app runs perfectly on Samsung Galaxy S Advance but the objects are out of scope on smaller screens such as that of Samsung Galaxy Fit or Pop. 该应用程序可以在Samsung Galaxy S Advance上完美运行,但是对象在较小的屏幕(例如Samsung Galaxy Fit或Pop的屏幕)上超出范围。 How do i make it compatible for all screen sizes and pixel densities. 如何使它与所有屏幕尺寸和像素密度兼容。 Using dpis seems out of the question as I'm not using any xml layouts. 使用dpi似乎是不可能的,因为我没有使用任何xml布局。

Thanks in advance. 提前致谢。

我认为您应该在运行时获得屏幕分辨率,并据此设置像素。

According to the developer guidelines it is discouraged to do so (work with explicit coordinates). 根据开发人员指南,不建议这样做(使用显式坐标)。 Please refer to the android design guidelines for how to do it better. 请参阅android设计指南,了解如何做得更好。 If you cannot avoid it, you'll need to take into account the screen size and density and compute your coordinates accordingly. 如果无法避免,则需要考虑屏幕尺寸和密度并相应地计算坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM