I need to make 2 screens with custom animation like explained below :
Screen 1 Screen 2
----------------------------- ------------------------------
| | | | | |
| | | | | |
| | | | | |
| List 1 | List2 | ---------> | List 3 | List 4 |
| (75% width) |(25% wid)| |(25%wid)| (75% width) |
| | | | | |
| | | | | |
----------------------------- ------------------------------
- User makes a long touch on an item in List 1 and slides from left to right.
- The view containing List 1 moves from left to right (till the end of the screen) and fades. Screen 2 is shown.
I have put each of the lists in a LinearLayoutand all the LinearLayouts is contained in a root LinearLayout. After detecting the left to right swipe on List1, I do this
AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.75f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
animation.setDuration(500);
animation.setZAdjustment(Animation.ZORDER_TOP); // Keep the viewgroup on which this animation applies at the top.
set.addAnimation(animation);
LayoutAnimationController controller =
new LayoutAnimationController(set, 0.0f);
screenOne_layoutOne.setLayoutAnimation(controller);
screenOne_layoutOne.startLayoutAnimation();
I was able to get the animation but the screenOne_layoutOne(layout containing the List 1) doesn’t stay on top. The animation goes below List2.
Can anyone tell me where the problem is?
Thanks in advance.
For those of you who are interested, I was able to get this solved by putting the layouts of both the screens in a single layout file and changing the
visibilityof the layouts/views. The layout file used iswhen I applied the animation(
anim) on list1(featured_list), it stays on top if I do