Please please please do not use Display to do your layout. This tells you the raw size of the display; it is not directly associated with the UI.
The correct way to do this kind of stuff, always, is to do the layout during the layout pass. Please don't skimp on this. It is VERY IMPORTANT that you participate in the framework in the right way here, using the size information available in the view hierarchy as part of layout, to make sure you do the right thing!!! Otherwise you can expect to run in to problems in the future as you encounter devices with new and interesting kinds of screens. We do a lot of work in the framework to help applications deal with this, but if you go behind its back with Display and otherwise don't participate as a good citizen, it can't help and you will have troubles. Also, if you just want to find out whether you are running on a portrait or landscape orientation, please just use getResources().getConfiguration() and look at the orientation there. Again, Display is a low-level facility and not what you want. DO NOT USE IT. Thanks. On Thu, Dec 3, 2009 at 1:54 PM, Greg Donald <[email protected]> wrote: > On Thu, Dec 3, 2009 at 3:48 PM, Mark Wyszomierski <[email protected]> > wrote: > > Hi Justin, > > > > I was contemplating writing my own layout manager for this task, but > > don't know if it's necessary. I have a list of 8 panels to show, > > whether they all fit on screen or not (they're housed in a ListView). > > This is like a default set of buttons: > > > > "Apple" > > "Orange" > > ... > > "Grape" > > > > If I can see that the screen is tall enough to hold a few additional > > items, I'd like to add one or two additional panels: > > > > += > > "Lemon" > > "Pear" > > > > so it's not critical, but would be nice if I could maximize the number > > of elements in the list (without scrolling) before the UI is displayed > > for the first time, > > > > Thanks > > I handle the different resolutions like this: > > private Display defaultDisplay; > private int displayHeight; > private boolean extraTall; > > [...] > > defaultDisplay = getWindow().getWindowManager().getDefaultDisplay(); > displayHeight = defaultDisplay.getHeight(); > > extraTall = displayHeight > 480; > > if( extraTall ) > { > // make layout changes here > > } > > The same can be done with regards to landscape mode and width. > > > -- > Greg Donald > http://destiney.com/ > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

