onSizeChanged, which gives the size of the view, is one thing.

But you keep saying *screen* dimensions, which is quite another.

If that's what you need, you can use DisplayMetrics:

http://developer.android.com/reference/android/util/DisplayMetrics.html

Check out widthPixels and heightPixels, which give screen size.

-- Kostya

22.12.2010 12:18, Utumno пишет:
Yes, I mean onSizeChanged().

Hmm, no way? Even if I have android:screenOrientation="landscape" in
my manifest ? This way screen dimensions will ( am I right? ) never
change,  and should be accessible anytime...

Currently I initialize part of my View in its constructor, than I have
to do all kinds of locks to somehow survive without a crash until I
get the onSizeChanged() message and can initialize the rest (which
depends on screen size ) and then I have to ignore subsequent
onSizeChanges() which, for some reason, still sometimes come ( even
though, of course, neither the physical screen size nor orientation
has actually changed ). For example, if I have my app on top, and
screen saver kicks in, and I awake the screen,  then my app gets shown
again and gets ( in my opinion, spurious ) onSizeChanged() message
which needs to be ignored.

Doing the above is feasible, but messy. It would be way more
convenient if I could simply figure out the screen dimensions in
View's constructor, construct everything and do not bother with
onSizeChanged  ( like I do in versions of said app for Symbian and
Blackberry )




On Dec 22, 4:51 pm, Dianne Hackborn<[email protected]>  wrote:
You mean onSizeChanged()?

Sorry, there is nothing earlier, that is the point where this has been
figured out.



On Tue, Dec 21, 2010 at 11:59 PM, Utumno<[email protected]>  wrote:
Hello Android gurus,
I am aware that when screen dimensions change, I get a call to
onScreenChanged() and there I can figure out its dimensions, however
it would be much more convenient if I could figure this out earlier,
namely in my View's constructor.
Any tips?
--
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.


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to