Displaying Deck of Cards on Android's Different Screen Sizes

392 views Asked by At

I'd like to display a face up deck of 52 cards in an Android app. I have the png/svg/bitmap files and the xml layout. I'm unsure of the settings necessary that will cause the app to resize the images to fit the screen the images are being displayed on. I've attached a mockup image of what I am trying to do. Any pointers to the right documentation to help clear this up for me? enter image description here

1

There are 1 answers

0
Jim On

It depends on how you build the layouts. But essentially you should look into using displayMetrics:

How to get screen display metrics in application class

You can use that to determine the size (width/height) of the screen.

You could also use nested, weighted LinearLayouts :

How to set layout_weight attribute dynamically from code?

There might be warnings about it being "slow" - but with this type of situation, it's unlikely to be noticeable.