title: Android, ObjectAnimator lagging on two overlapping Layouts
body: <p>i got a problem with my App regarding smoothness on two overlapping Layouts. I built some kind of slide menu (like Facebook or YouTube). This menu contains two layouts: the main layout which displays the data and includes the menu layout underneath it. And then the menu layout itself, a normal ListView with custom Row Layout.</p>
  
  <p>Main:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
  &lt;include
          android:id="@+id/menu_list"
          layout="@layout/menu_list"/&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/news_content"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#FFF"
                android:orientation="vertical"&gt;
      &lt;ListView
              android:id="@android:id/list"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/&gt;
  
   &lt;/LinearLayout&gt;
  
   &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
      &lt;ProgressBar
              android:id="@+id/NewsProgressBar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:visibility="gone"
              style="@android:style/Widget.Holo.Light.ProgressBar.Large"/&gt;
  
   &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Menu:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="250dip"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:background="@drawable/ic_sidebar_bg"&gt;
  
  &lt;RelativeLayout
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"&gt;
  
      &lt;ImageView
              android:alpha="0.8"
              android:layout_height="40dp"
              android:layout_width="match_parent"
              android:background="#222222"/&gt;
  
      &lt;TextView
              android:layout_height="wrap_content"
              android:layout_width="wrap_content"
              android:layout_marginLeft="10dip"
              android:layout_marginTop="12dip"
              android:textSize="14dp"
              android:textColor="#666"
              android:text="@string/menu_cat_main"/&gt;
  
      &lt;ImageView
              android:layout_height="1dp"
              android:layout_marginTop="40dp"
              android:layout_width="match_parent"
              android:background="#666666"/&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;ListView
          android:id="@+id/mainMenuList"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I recognized already that this overlapping causes ListViews to lag horribly. What i've done then was to make the menu include "visibility:gone", which causes the ListViews to work absolutely fine. But if i try to slide the content sidewards, the include (menu) gets visible again and the slide is everything else than smooth. But except this cosmetical issue, the menu is working exactly like the one from YouTube.</p>
  
  <p>To make things clear regarding the following code:
  viewContent (View) contains the LinearLayout with its Content
  viewMenu (View) contains the menu layout include
  canSlide (bool) whenever the menu can be slided by touch or not (true of certain area of screen is touched)
  isMenuScrolled (bool) whenever the menu is slided out or not</p>
  
  <p>Here the Code from the touch event:</p>
  
  <pre><code>public boolean dispatchTouchEvent(MotionEvent touchevent) {
  
      switch (touchevent.getAction()) {
          case MotionEvent.ACTION_MOVE:
  
              if (canSlide) {
                  if (touchevent.getX() &lt; viewMenu.getWidth()) {
                      viewContent.setX(touchevent.getX());
                  } else if (touchevent.getX() &lt; 0) {
                      viewContent.setX(0);
                  } else if (touchevent.getX() &gt; viewMenu.getWidth()) {
                      viewContent.setX(viewMenu.getWidth());
                  }
  
                  viewContent.setEnabled(false);
              }
              return true;
  
          case MotionEvent.ACTION_DOWN:
  
              if (touchevent.getY() &gt; 200 &amp;&amp; touchevent.getX() &lt; 50 &amp;&amp; !isMenuScrolled) {
                  viewMenu.setVisibility(View.VISIBLE);
                  touchStart = touchevent.getX();
                  canSlide = true;
              } else if (touchevent.getY() &gt; 200 &amp;&amp; touchevent.getX() &gt; viewMenu.getWidth() &amp;&amp; isMenuScrolled) {
                  viewMenu.setVisibility(View.VISIBLE);
                  touchStart = touchevent.getX();
                  canSlide = true;
              } else {
                  canSlide = false;
              }
              return true;
  
          case MotionEvent.ACTION_UP:
  
              if (viewContent.getX() != 0 || viewContent.getX() != viewMenu.getWidth()) {
                  if (viewContent.getX() &lt; touchStart) {
                      ObjectAnimator transAnimation = ObjectAnimator.ofFloat(viewContent, "x", viewContent.getX(), 0);
  
                      transAnimation.addListener(new Animator.AnimatorListener() {
  
                          @Override
                          public void onAnimationStart(Animator animator) {
                              viewContent.setEnabled(false);
                              isMenuScrolled = false;
                          }
  
                          @Override
                          public void onAnimationEnd(Animator animation) {
                              viewMenu.setVisibility(View.GONE);
                              viewContent.setEnabled(true);
                          }
  
                          @Override
                          public void onAnimationCancel(Animator animator) {
                              // nothing
                          }
  
                          @Override
                          public void onAnimationRepeat(Animator animator) {
                              // nothing
                          }
  
                      });
  
                      transAnimation.setDuration(300);
                      transAnimation.start();
  
                  } else if (viewContent.getX() &gt; touchStart) {
                      ObjectAnimator transAnimation = ObjectAnimator.ofFloat(viewContent, "x", viewContent.getX(), viewMenu.getWidth());
  
                      transAnimation.addListener(new Animator.AnimatorListener() {
  
                          @Override
                          public void onAnimationStart(Animator animator) {
                              viewContent.setEnabled(false);
                              isMenuScrolled = true;
                          }
  
                          @Override
                          public void onAnimationEnd(Animator animation) {
                              viewContent.setEnabled(true);
                          }
  
                          @Override
                          public void onAnimationCancel(Animator animator) {
                              // nothing
                          }
  
                          @Override
                          public void onAnimationRepeat(Animator animator) {
                              // nothing
                          }
  
                      });
  
                      transAnimation.setDuration(300);
                      transAnimation.start();
                  }
              }
              return true;
      }
  
      return true;
  }
  </code></pre>
  
  <p>How can I resolve this problem, making it scroll a bit more smooth?
  One last thing, whats the best way to disable the Content while scrolling the menu? viewContent.setEnabled isn't working as it should.</p>
  
  <p>BIG Thanks in advance!</p>