• 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
Mar 30, 2019
149
52
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?
 
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: 82
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones