1. Are you ready for the Galaxy S20? Here is everything we know so far!

Positioning Objects

Discussion in 'Android Development' started by Brian Berry, Apr 15, 2019.

  1. Brian Berry

    Brian Berry Well-Known Member
    Thread Starter

    I have about 100 objects to a game I'm building. I tried to use a constraint layout which worked fine on my pixel 3 phone but was inconsistent on all other phones. So now I'm getting screen resolution and setting X and Y for each object which works great except as you know there are so many phones out there. Should I collect phones and continue getting resolution and manually set each element? Any insight into this subject would be greatly appreciated. How are UI consistently made?


  2. What do you use as objects? Do you use widgets as your game objects? such as a button?
    You say "So now I'm getting screen resolution...". How do you get resolution?
  3. Brian Berry

    Brian Berry Well-Known Member
    Thread Starter

    Thanks for your reply maksim. I finally broke down and played with most aspects of the Android layout editor and figured stuff out. It was key for me to use constraint layout with a bunch of guideline helpers set to percentage and then configure each imageView Object and Text View within the XML to use a
    app:layout_constraintDimensionRatio of 16:9 and app:layout_constraintStart_toStartOf the guidlines. In the end it took me 6 days to learn to make a complex constraint layout. I now feel confident to take on any layout that will look good on multiple phones. Here is what the final constraint layout looks like. Its a blackjack game that I made to learn to make simple Android games.


    Attached Files:


Share This Page