[android-developers] TranslateAnimation z-order problem

2010-02-18 Thread mc_sunw
I've come across a curious problem:

I have a simple horizontal LinearLayout: Button A - ViewGroup
(vertical LinearLayout containing TextViews) - Button B
It's important to note that the views are defined in the XML in the
above order i.e. Button A, ViewGroup, Button B.

I have a simple TranslateAnimation:
1. Press Button A and the ViewGroup gets animated off the screen to
the right, past Button B.
2. Press Button B and the ViewGroup gets animated off the screen to
the left, past Button A.

In the case of #1, the animation happens with the ViewGroup being
animated *behind* Button B.
In the case of #2, the animation happens with the ViewGroup being
animated *above* Button A.

This happens specifically because Button A was defined before the
ViewGroup in the layout XML.  I've tried changing the Z adjustment for
the animation but this has no effect.

What I want is to have both animations happen behind the buttons (i.e
#2 same as #1).  I don't want to have to re-arrange my layout to have
to define the ViewGroup first and I've tried bringing Button A to the
front but that messes with the overall layout when the ViewGroup is
off the screen, with Button A ending up next to Button B on the right.

Any ideas?  It seems like the Z adjustment isn't doing what it should.

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


[android-developers] Re: TranslateAnimation z-order problem

2010-02-18 Thread mc_sunw
Ok, so it's not me doing something stupid. :)

Any thoughts as to the best solution?

I wrote a simple test whereby I created a RelativeLayout rather than a
LinearLayout and defined the ViewGroup first and the buttons after,
relative to the ViewGroup, which seemed to work ok in the test.  So
did calling buttonA.bringToFront() before starting the animation
(although it screwed up the layout after the animation was complete by
putting the Button A on the far right next to Button B).  Neither seem
a very elegant solution to what must be quite a common problem (I
really don't want to have to re-define my whole layout again as that
has implications for the whole app).

On Feb 18, 7:45 pm, Dianne Hackborn hack...@android.com wrote:
 The Z adjustment only works for window animations.  I thought this was
 documented, but apparently not.





 On Thu, Feb 18, 2010 at 8:25 AM, mc_sunw mlcaun...@googlemail.com wrote:
  I've come across a curious problem:

  I have a simple horizontal LinearLayout: Button A - ViewGroup
  (vertical LinearLayout containing TextViews) - Button B
  It's important to note that the views are defined in the XML in the
  above order i.e. Button A, ViewGroup, Button B.

  I have a simple TranslateAnimation:
  1. Press Button A and the ViewGroup gets animated off the screen to
  the right, past Button B.
  2. Press Button B and the ViewGroup gets animated off the screen to
  the left, past Button A.

  In the case of #1, the animation happens with the ViewGroup being
  animated *behind* Button B.
  In the case of #2, the animation happens with the ViewGroup being
  animated *above* Button A.

  This happens specifically because Button A was defined before the
  ViewGroup in the layout XML.  I've tried changing the Z adjustment for
  the animation but this has no effect.

  What I want is to have both animations happen behind the buttons (i.e
  #2 same as #1).  I don't want to have to re-arrange my layout to have
  to define the ViewGroup first and I've tried bringing Button A to the
  front but that messes with the overall layout when the ViewGroup is
  off the screen, with Button A ending up next to Button B on the right.

  Any ideas?  It seems like the Z adjustment isn't doing what it should.

  --
  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+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Dianne Hackborn
 Android framework engineer
 hack...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en