简体   繁体   English

如何确保我的应用程序与每台Android设备兼容,并将视图缩放以适​​合不同的屏幕尺寸?

[英]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. 非常感谢,谢谢。

暂无
暂无

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

相关问题 如何使图像适合Android应用程序上的所有设备 - How can I make images fit every device on android application 如何使我的应用程序与所有屏幕尺寸兼容,而无需为其创建不同的布局文件? - how can i make my app compatible with all screen sizes without making different layout files for it? 如何进行布局,使Cardview与每个Android屏幕尺寸的设备兼容? - How to make a layout, with cardviews compatible for every android screen size device? 如何使用不同类型的屏幕缩放字体? - How can I scale my font with different types of screen? 我需要找到一种方法来缩放我的网格以适应 Flutter 中设备的正确屏幕尺寸 - I need to find a way to scale my grid to fit the proper screen size of a device in Flutter Android应用的屏幕尺寸不适合设备 - Android app screen size does not fit device 不论设备大小如何,都可以将多个Android ImageViews缩放为适合所有屏幕 - Scale multiple Android ImageViews to All Fit on Screen Regardless of Device Size 制作新项目时,如何确保我的Android应用程序可以在3个不同版本的Android上运行? - When making a new project, how do I ensure my Android App will run on 3 different versions of Android? 我如何找出为什么设备与我的应用程序不兼容 - How do I find out why a device is not compatible with my app 当分辨率对于屏幕尺寸来说太高时,我可以缩放完整的 Flutter 应用程序吗? - Can I scale a complete flutter app when the resolution is too high for the screen dimensions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM