Sunday, July 22, 2012

Re: [android-developers] Usage of DisplayMetrics

On Sun, Jul 22, 2012 at 5:21 AM, Jim Graham <spooky130u@gmail.com> wrote:
That's probably what I'm not clear on....  What is "everything else"
in this case?  If display.getWidth and display.getHeight report that
my tablet's display size is 1280x752 (which, I just discovered, is NOT
what Settings-->About Tablet-->System Information-->display pixels
reports---it reports 1280x800) ... hmmmm ....  so which is right?

Given that you can have an arbitrary set of system controls around the screen, carving out an arbitrary amount of space from the size available to apps, that can be shown or hidden at arbitrary times, what does "display size" mean?  (Not to mention more complicated organizations like say the screen being split to show multiple applications.  Or other decorations within the window like the action bar.)

The right way to do this is to put your UI up, giving the information to the system about how it should be shown, and letting it go through a layout with the screen to finally position and size your view that displays your content of interest, retrieving the size there.

I see what this is all about now.  So display.getWidth/Height reports
the wrong numbers, and View.getWidth() and View.getHeight() returns the
correct display size?

It doesn't report the wrong numbers, it just can't guarantee to report the actual size that your view showing its content will have.

Plus, you really want to be driven by being *told* the size of your view, since this can change over time, and you want to respond when it does.  Pulling a size from somewhere and assuming that is fixed is a rigidity in your app that you should avoid.

--
Dianne Hackborn
Android framework engineer
hackbod@android.com

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate