Note that there are some explanatory texts on larger screens.

plurals
  1. POexplicitly lay out UI
    text
    copied!<p>I'm finding the need to lay out a fairly complex UI manually, by giving the dimensions and position of most all of the sub views. My plan is to code the XML initially for a 480x320 display, get it all working right to demo for the client on a given device, then modify it for production by programmatically adjusting the size and position of the views to adapt it to whatever screen size it's running on.</p> <p>First...I know this is not the recommended approach. I have spent forever trying to get the automated layouts to work right (along with animations). Honestly I don't think they were made for the way the client wants this, and I just don't have any more time to mess around with it. (nor to learn to make a flexible custom layout)</p> <p>Given that, where should I do the measuring/positioning? I can do onMeasure() to set the sizes (ignoring the incoming parameters and basing them instead on my knowledge of the screen resolution which is measure when the Activity starts), but where do I set the position of each the view? In onLayout()? Assume all views will be subclasses anyway (as opposed to using components out of the box)</p> <p>Ideally, I'd like to have one place where I measure the screen res, then grab each view and set its x, y, width and height. Is that possible? If so how?</p> <p>Edit: now offering a bounty. Note that I also did a sketch of one simple problem I'm trying to solve -- <a href="http://karmalita.com/stuff/layout.png" rel="nofollow">http://karmalita.com/stuff/layout.png</a> -- which if you can do it the "correct" way (say, using a relative layout), the bounty is yours.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload