tags:

views:

254

answers:

1

I'm trying to do something which seems simple. I want to have a map view, with a menu that slides up from the bottom of the screen where settings (for overlay) can be adjusted. However when I use a TranslateAnimation to affect the y position of the LinearLayout (which holds the menu), the buttons in the LinearLayout move, but there "hit area" stays in the same position as they were before the animation.

    TranslateAnimation slide = new TranslateAnimation(0,0,0,0);
 slide.setDuration(300);
 slide.setFillAfter(true);
 pullupMenu.startAnimation(slide);
 mapContainer.startAnimation(slide);

I've also looked into tweening the view's marginTop value, but haven't even been able to determine how that would be done.

Any help on either of these directions would be much appreciated.

+1  A: 

The animation in general is animating the pixels of the widget. My suspicion, based on what you wrote, is that setFillAfter() merely arranges for the pixels to stay in the destination location, not the widget itself.

If you want the animation to actually wind up moving the widget, you need to:

  • Register a listener to find out when the animation ends, and
  • Arrange at that point to modify the layout rules such that the widget actually exists in the new location

You can see a sliding pane that employs this technique here.

CommonsWare