title: Both Sided Slide menu in android
body: <p>This is not a duplicate of any questions asked before.
  I want a double sided slide menu.
  I <a href="https://github.com/jaylamont/AndroidFlyOutMenuDemo." rel="nofollow">referred this library</a></p>
  
  <p>I tried to edit this project and here are my corresponding files:
  <strong>Sample Activity.java</strong></p>
  
  <pre><code>package com.example.flyoutmenuexample;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  
  import com.example.flyoutmenuexample.view.viewgroup.FlyOutContainer;
  
  public class SampleActivity extends Activity {
  
      FlyOutContainer root;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          this.root = (FlyOutContainer) this.getLayoutInflater().inflate(
                  R.layout.activity_sample, null);
          this.setContentView(root);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.sample, menu);
          return true;
      }
  
      public void toggleLeftMenu(View v) {
          this.root.toggleLeftMenu();
      }
  
      public void toggleRightMenu(View v) {
          this.root.toggleRightMenu();
      }
  
  }
  </code></pre>
  
  <p><strong>FlyOutContainer.java</strong></p>
  
  <pre><code>package com.example.flyoutmenuexample.view.viewgroup;
  
  import android.content.Context;
  import android.os.Handler;
  import android.util.AttributeSet;
  import android.view.Display;
  import android.view.View;
  import android.view.WindowManager;
  import android.view.animation.Interpolator;
  import android.widget.LinearLayout;
  import android.widget.Scroller;
  
  public class FlyOutContainer extends LinearLayout {
  
      Context ctx = getContext();
      WindowManager wm = (WindowManager) ctx
              .getSystemService(Context.WINDOW_SERVICE);
      Display display = wm.getDefaultDisplay();
      int width = display.getWidth(), height = display.getHeight();
  
      // References to groups contained in this view.
      private View leftMenu, rightMenu;
      private View content;
  
      // Layout Constants
      protected static final int menuMargin = 150;
  
      public enum MenuState {
          CLOSED, OPEN, CLOSING, OPENING
      };
  
      // Position information attributes
      protected int currentContentOffset = 0;
      protected MenuState menuCurrentState = MenuState.CLOSED;
  
      // Animation objects
      protected Scroller menuAnimationScroller = new Scroller(this.getContext(),
              null);
      // new LinearInterpolator());
      // protected Scroller menuAnimationScroller = new
      // Scroller(this.getContext(),
      // new SmoothInterpolator());
      protected Runnable menuAnimationRunnable = new AnimationRunnable();
      protected Handler menuAnimationHandler = new Handler();
  
      // Animation constants
      private static final int menuAnimationDuration = 500;
      private static final int menuAnimationPollingInterval = 16;
  
      public FlyOutContainer(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      public FlyOutContainer(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public FlyOutContainer(Context context) {
          super(context);
      }
  
      @Override
      protected void onAttachedToWindow() {
          super.onAttachedToWindow();
  
          this.leftMenu = this.getChildAt(0);
          this.content = this.getChildAt(1);
          this.rightMenu = this.getChildAt(2);
  
          this.leftMenu.setVisibility(View.GONE);
          this.rightMenu.setVisibility(View.GONE);
      }
  
      @Override
      protected void onLayout(boolean changed, int left, int top, int right,
              int bottom) {
          if (changed)
              this.calculateChildDimensions();
  
          this.leftMenu.layout(left, top, right - menuMargin, bottom);
  
          this.content.layout(left + this.currentContentOffset, top, right
                  + this.currentContentOffset, bottom);
          this.rightMenu.layout(left +menuMargin, top, right, bottom);
  
      }
  
      public void toggleLeftMenu() {
          switch (this.menuCurrentState) {
          case CLOSED:
              this.menuCurrentState = MenuState.OPENING;
              this.leftMenu.setVisibility(View.VISIBLE);
              this.menuAnimationScroller.startScroll(0, 0,
                      this.getLeftMenuWidth(), 0, menuAnimationDuration);
              break;
          case OPEN:
              this.menuCurrentState = MenuState.CLOSING;
              this.menuAnimationScroller.startScroll(this.currentContentOffset,
                      0, -this.currentContentOffset, 0, menuAnimationDuration);
              break;
          default:
              return;
          }
  
          this.menuAnimationHandler.postDelayed(this.menuAnimationRunnable,
                  menuAnimationPollingInterval);
  
          this.invalidate();
      }
  
      public void toggleRightMenu() {
          switch (this.menuCurrentState) {
          case CLOSED:
              this.menuCurrentState = MenuState.OPENING;
              this.rightMenu.setVisibility(View.VISIBLE);
              this.menuAnimationScroller.startScroll(this.width, 0,
                      this.getRightMenuWidth(), 0, menuAnimationDuration);
              break;
          case OPEN:
              this.menuCurrentState = MenuState.CLOSING;
              this.menuAnimationScroller.startScroll(this.currentContentOffset,
                      0, this.currentContentOffset, 0, menuAnimationDuration);
              break;
          default:
              return;
          }
          this.menuAnimationHandler.postDelayed(this.menuAnimationRunnable,
                  menuAnimationPollingInterval);
  
          this.invalidate();
      }
  
      private int getRightMenuWidth() {
          return  this.rightMenu.getLayoutParams().width;
      }
  
      private int getLeftMenuWidth() {
          return this.leftMenu.getLayoutParams().width;
      }
  
      private void calculateChildDimensions() {
          this.content.getLayoutParams().height = this.getHeight();
          this.content.getLayoutParams().width = this.getWidth();
  
          this.leftMenu.getLayoutParams().width = this.getWidth() - menuMargin;
          this.leftMenu.getLayoutParams().height = this.getHeight();
  
          this.rightMenu.getLayoutParams().width = this.getWidth() - menuMargin;
          this.rightMenu.getLayoutParams().height = this.getHeight();
      }
  
      private void adjustContentPosition(boolean isAnimationOngoing) {
          int scrollerOffset = this.menuAnimationScroller.getCurrX();
  
          this.content.offsetLeftAndRight(scrollerOffset
                  - this.currentContentOffset);
  
          this.currentContentOffset = scrollerOffset;
  
          this.invalidate();
  
          if (isAnimationOngoing)
              this.menuAnimationHandler.postDelayed(this.menuAnimationRunnable,
                      menuAnimationPollingInterval);
          else
              this.onMenuTransitionComplete();
      }
  
      private void onMenuTransitionComplete() {
          switch (this.menuCurrentState) {
          case OPENING:
              this.menuCurrentState = MenuState.OPEN;
              break;
          case CLOSING:
              this.menuCurrentState = MenuState.CLOSED;
              this.leftMenu.setVisibility(View.GONE);
              break;
          default:
              return;
          }
      }
  
      protected class SmoothInterpolator implements Interpolator {
  
          @Override
          public float getInterpolation(float t) {
              return (float) Math.pow(t - 1, 5) + 1;
          }
  
      }
  
      protected class AnimationRunnable implements Runnable {
  
          @Override
          public void run() {
              FlyOutContainer.this
                      .adjustContentPosition(FlyOutContainer.this.menuAnimationScroller
                              .computeScrollOffset());
          }
  
      }
  }
  </code></pre>
  
  <p><strong>activity_sample.xml</strong></p>
  
  <pre><code>    &lt;com.example.flyoutmenuexample.view.viewgroup.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;!-- Left Drawer Starts --&gt;
  
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="#444488"
          android:orientation="vertical" &gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleLeftMenu"
              android:text="Button 1" /&gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleLeftMenu"
              android:text="Button 2" /&gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleLeftMenu"
              android:text="Button 3" /&gt;
      &lt;/LinearLayout&gt;
      &lt;!-- Left Drawer Ends --&gt;
  
  
      &lt;!-- Center Starts --&gt;
  
      &lt;RelativeLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/rel"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="#888888"
          android:orientation="vertical" &gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:lines="2"
              android:onClick="toggleLeftMenu"
              android:text="Toggle Left" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentRight="true"
              android:layout_alignParentTop="true"
              android:lines="2"
              android:onClick="toggleRightMenu"
              android:text="Toggle Right" /&gt;
      &lt;/RelativeLayout&gt;
      &lt;!-- Center Ends --&gt;
  
  
      &lt;!-- Right Starts --&gt;
  
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="#444488"
          android:orientation="vertical" &gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleRightMenu"
              android:text="Button 1" /&gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleRightMenu"
              android:text="Button 2" /&gt;
  
          &lt;Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:onClick="toggleRightMenu"
              android:text="Button 3" /&gt;
      &lt;/LinearLayout&gt;
      &lt;!-- Right Ends --&gt;
  
  &lt;/com.example.flyoutmenuexample.view.viewgroup.FlyOutContainer&gt;
  </code></pre>
  
  <p><em>The logical problem that I am facing is that</em> <strong>on clicking the right toggle button the slide menu from right comes out with no animation and it cover equal amount of screen like left slide menu does, but the background main content screen gets disappeared</strong></p>
  
  <p><strong>I have given in depth detail about my problem, you can directly copy-paste these files and run the project for better understanding of my problem</strong></p>
  
  <p>thanks
  regards</p>