Flexible Android layout for multiple screen sizes / densities

I am working on a card game for Android. I'm trying to come up with a layout that will allow you to play the game on all screen sizes and densities.

I read: http://developer.android.com/guide/practices/screens_support.html

However, I'm still confused about the best way to do this.

For this game I need maps laid out in landscape mode, in 5 columns. For additional maps, there are places above 5 columns. This is very similar to solitaire in this regard ... but I only need 5 columns instead of 7.

What should be the images of maps in size in ldpi, mdpi and hdpi?

What type of layout should I use (table, linear, relative)?

Should I create different layouts for different screen sizes (small, regular, large)?

Any examples you can point me to?

+4
source share
2 answers

The Android documentation contains a great guide on the topic:

Multi screen support

They introduce generalized sizes and densities and show how different resources can be dynamically loaded for different screens.

I'm new to android, so don’t think about it, but I think you can get away with one layout for all screen sizes, and I think RelativeLayout will work well (in most cases) especially with something complicated like a card the game. I mainly used LinearLayouts inside RelativeLayouts when I wanted to align the buttons / text horizontally.

0
source

Firstly, I regret that my English is not good enough. You must separate your resources into several folders (based on screen size), for example, create different layouts from different resources. You can do the following:

1.drawable

-drawable-hdpi -drawable-mdpi -drawable-ldpi 

2.layout

 --layout-hdpi --layout-mdpi --layout-ldpi 

adjust your resource for each screen size, this makes your application applicable to many devices.

+8
source

Source: https://habr.com/ru/post/1335259/


All Articles