• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Positioning Objects

Brian Berry

Well-Known Member
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?
 
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?
 
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.

--calmchess
 

Attachments

  • bjlayout0.png
    bjlayout0.png
    217.5 KB · Views: 91
Back
Top Bottom