简体   繁体   中英

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. 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. 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?

I have a large image in my MainActivity but for some reason it gets really small if I switch to landscape.

Can anybody shed some light on this? Would be really grateful, thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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