在多个 Android 屏幕上显示
我编写了一个自定义视图,并使用 onSizeChanged() 来获取手机的宽度和高度。当我安装在手机上的模拟器中一切看起来都正确时(htcdesire),但我没有相同的结果!
我该怎么做才能支持不同的屏幕?onSizeChanged 不应该给我解决方案?
i have write a custom view and i used the onSizeChanged() to take the width and height of the phone.when everything seems right in the emulator i installed on the phone(htc desire) and i don't have the same results!
what can i do to support different screens than one?onSizeChanged shouldn't give me the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须注意像素密度和像素数量。
一切都在这里: http://developer.android.com/guide/practices/screens_support.html
You have to take care of the pixel density and the number of pixels.
Everything is here : http://developer.android.com/guide/practices/screens_support.html
答案在很大程度上取决于您的布局,如果没有更多详细信息,最好的开始显然是 官方教程。
首先要了解的是您想要支持的设备集。您的应用程序仅适用于智能手机吗?平板电脑?两个都?然后,您想要支持哪些屏幕尺寸、分辨率和密度?您希望您的应用能够优雅地适应不受支持的设备,还是希望它隐藏在 Play 商店中?
一般来说,您不应该在 Java 方面进行工作,而应该在资源方面进行更多工作(即使有时这是不可能的)。
The answer depends a lot on your layout, and without more details the best thing to start is obviously the official tutorial.
The first thing to know, is the set of devices you want to support. Is your app only for smartphone? Tablets? Both? And then, which screen sizes, resolutions and densities you want to support? You want your app to gracefully adapt to the unsupported devices, or you want it to be hidden on the Play Store?
In general, you shouldn't do the work on the Java side, but more on the resources side (even if sometimes is not possible).