简体   繁体   中英

Different resolutions on Android game

how can I develop a game for different screen resolutions? I have already read about Density independant pixels (dp), but I still don't know how to use them. For example, what size should my View have in order to be fully displayed in every device? Can I just set it to 1280dp x 800dp and start drawing things on my canvas related to this size?

No, since the devices not only have different density, but also different ratios.

The easiest way is to decide your ratio (1,667 is the most popular) and create a canvas of that size. Then linearly scale the height(or the width) to match the device's one, and put black rectangles on the borders. It will work without borders in a big majority of the devices, and it will still look right on the others. This way you have the big advantage of always knowing the relative distance between your objects.

Btw i suggest you to use a graphic engine that handles it for you (for example andengine)

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