0

Now I have a simple layout like this:

-----------------------------------
   button1       |       button2  
-----------------------------------
 Welcome to my App.

When the user clicks button1, I want to show a side bar from right (swipes in smoothly), and move two buttons smoothly to left side:

-----------------------------------
button1|button2|      Side bar    
---------------|
Welcome        |
to my App.     |    some text that
               |    shows some infos

And when I click button1 again, the sidebar should disappear (swiping to right) and we got the same layout as the first one.

Now I have two questions:

  1. The side bar that I want is not really a navigation bar, so I do not want to use the sidebar in Android. Is there any other alternatives better for my use?

  2. How can I achieve that, when the side bar appears from the right, move everything (including two buttons and text) to the left to give space for side bar? Is there a way to do this properly?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
hawarden_
  • 1,904
  • 5
  • 28
  • 48

1 Answers1

0

You can use TranslateAnimation like this

TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 150);  //use Sidebar.length() to move according to sidebar                          
                            anim.setDuration(1000);
                            anim.setFillAfter(true);
                            animWindow.setDuration(1000);
                            animWindow.setFillAfter(true);
                            button1.setAnimation(anim);
                            button2.setAnimation(anim);
Kapil Parmar
  • 881
  • 8
  • 19