That's my point, don't try to compute the center position, just let the
animation framework do it for you by declaring your animation with the
correct values.

On Wed, Jun 17, 2009 at 10:17 PM, Beth <[email protected]> wrote:

>
> Thanks Romain.
> So, when does the first layout happen?  The XML tip looks good but I
> cannot see how to use it to determine the centerpoint of my screen in
> the Java code.   I thought I could get layout components and their
> dimensions after setContentView had done its work.  My app animates a
> simple image view hosted in a Layout that uses the fill_parent width.
> Under that is a text view that doesn't move.  The width of the
> animation is the entire screen and should change when there is a
> switch from portrait to landscape.  How do I find my center point in a
> dynamic way?  My current solution is to set up a landscape layout with
> a fixed width on the animation view so it is the same as the portrait
> orientation.  What is the right way?
>
> On Jun 11, 6:08 pm, Romain Guy <[email protected]> wrote:
> > You cannot do that from onCreate(), you have to wait for the first
> > layout to happen. Besides, you don't need to hard code values in
> > animation since you can use values relative to a view, or its parent.
> > For instance, in XML, you can use 50%p to say "50% of the size of the
> > parent" or 40% to say "40% of the size of the animated view."
> >
> >
> >
> >
> >
> > On Thu, Jun 11, 2009 at 4:57 PM, Beth Mezias<[email protected]> wrote:
> > > Hi there,
> > > Can a layout expert offer insight here?  I have an animation in a
> lovely
> > > LinearLayout ViewGroup object that I get into Java from the XML using
> > > findViewById.  It's working great most of the time.  However, my first
> call
> > > to the animate function at the end of onCreate measures the width of
> this
> > > ViewGroup to be zero.  What am I missing?  The same object will return
> > > correct width measurements later in the thread of execution.  How can I
> get
> > > the correct measure from onCreate?
> > > Because of this behavior I have hard-coded values into my application
> for
> > > the Center X which might work nicely on the current HTC devices and
> then
> > > blow up later, or it might look bad in Europe on devices with different
> > > screen sizes. I tried a number of things to solve this (force layout,
> varied
> > > animation cache persistence, getMeasuredWidth instead of getWidth,
> > > invalidate on the ViewGroup and parent).  The layout and the
> component's
> > > measurements should be the same for onCreate as it is in another method
> in
> > > the Activity that responds to touch input from the user.  Also note
> that if
> > > I navigate in the app to another activity, change orientation, and then
> > > return to the first activity, this scenario also causes the ViewGroup's
> > > getWidth command to be zero.  That is why I assume the issue is related
> to
> > > onCreate.
> > > How do I get the correct measure of a (linearlayout) component when
> > > executing from onCreate?  Is there something in the window's drawing
> > > sequence that I need to workaround?
> > > Any tips or suggestions are most welcome.
> > > Regards,
> > > Beth
> >
> > --
> > Romain Guy
> > Android framework engineer
> > [email protected]
> >
> > Note: please don't send private questions to me, as I don't have time
> > to provide private support.  All such questions should be posted on
> > public forums, where I and others can see and answer them
> >
>


-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  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 Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to