[英]How can I ensure that my app is compatible with every Android device and will scale views to fit different screen dimensions?
I'm in the beginning stages of developing my first app and wanted to know what I can do from now to make sure my app runs equally well across all Android devices. 我正处于开发第一个应用程序的起步阶段,想知道从现在开始我能做些什么,以确保我的应用程序在所有Android设备上都能正常运行。 I don't have access to another device right now to test whether or not it will scale but have I noticed that if I rotate my device to landscape, the items in the view (eg buttons, icons) don't scale at all to fit the screen. 我现在无法访问其他设备来测试它是否可以缩放,但是我注意到如果将设备旋转到横向,视图中的项目(例如按钮,图标)根本无法缩放适合屏幕。 This makes me worry that it won't be very compatible with other devices. 这让我担心它不会与其他设备兼容。
I find myself putting items in each view by messing with paddings and margins in the XML till I have it right - but now I realise that this makes the layouts specific to my device. 我发现自己弄乱了XML中的填充和边距,从而在每个视图中放置了项目,直到我正确为止-但现在我意识到,这使布局成为我设备的特定布局。 Is there a "correct" way of doin this? 有这样做的“正确”方法吗? For instance, if I had to draw 4 horizontal lines equally spaced across the width of a screen how would I achieve this so that the width between the lines are determined according to the size of the screen? 例如,如果我必须绘制4条水平线,这些水平线在屏幕的宽度上等距分布,我将如何实现这一点,以便根据屏幕的尺寸确定线之间的宽度?
I have a large image in my MainActivity but for some reason it gets really small if I switch to landscape. 我的MainActivity中有大图像,但是由于某种原因,如果我切换到横向,则图像会变得很小。
Can anybody shed some light on this? 有人能对此有所启示吗? Would be really grateful, thanks. 非常感谢,谢谢。
This issue is addressed here: 此问题已在此处解决:
http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.