title: Android: How to swipe to dismiss whole layout?
body: <p>I have displayed custom layout (SYSTEM_ALERT_WINDOW) above all other views. I'm able to move with the custom layout using onTouch Event. </p>
  
  <p>I would like to add simple swipe to dismiss functionality on the X- axis. How can I do it in the right way, please? I tried to use same prepared libraries but seems that these libraries are designed for use in the listviews. </p>
  
  <p>I need only swipe in the x-axis to remove given layout.</p>
  
  <p>Many thanks for any advice.</p>
  
  <p>I tried to do following, i am able to move in the x-axis:</p>
  
  <pre><code>   mParentLayout.setOnTouchListener(new View.OnTouchListener() {
                  @Override
                  public boolean onTouch(View view, MotionEvent event) {
                      Logger.d("onTouch");
                      switch (event.getAction()) {
  
                          case MotionEvent.ACTION_DOWN:
  
                              dX = view.getX() - event.getRawX();
                              dY = view.getY() - event.getRawY();
                              break;
  
                          case MotionEvent.ACTION_MOVE:
                              view.animate()
                                      .x(event.getRawX() + dX)
                                      .setDuration(0)
                                      .start();
                              Logger.d(view.getX());
                              Logger.d(view.getRight());
                              Logger.d(view.getLeft());
  
                              break;
                          default:
                              return false;
                      }
                      return true;
                  }
              });
  </code></pre>