title: How to move Layout when scrollView scrolling?
body: <p><img src="https://i.stack.imgur.com/o6yTZ.png" alt="enter image description here"></p>
  
  <p>Hello everyone, i want to hide linearLayout when scrolllView scrolling up. 
  I try to make next:
   When I move my finger up on 1 px- move linearLayout up on 1 px, when LinearLayout become invisible, after that - move scrollview to top.</p>
  
  <pre><code> scrollView.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN: {                 
                      downXValue = event.getX();
                      downYValue = event.getY();
                      previousYvalue = downYValue;
                      break;
                  }
  
  
                  case MotionEvent.ACTION_UP: {
                      float currentY = event.getY();
                      if (downYValue &lt; currentY) {
                          previousYvalue = 0;                   
                          ((CompanyInfoActivityNew) getActivity()).setPanelMargin(0);
                          margin=0;
                          Log.v("", "down");
  
                      }
                      if (downYValue &gt; currentY) {
                          previousYvalue = 0;
                          ((CompanyInfoActivityNew) getActivity()).setPanelMargin(-230);
                          margin=-230;
                          Log.v("", "up");
  
                      }
                      //  }
                      break;
                  }
                  case MotionEvent.ACTION_MOVE: {
                      if (Math.abs(previousYvalue - event.getY()) &gt;2) {
                          previousYvalue = event.getY();
                          switch ((int) margin) {
                              case 0://LinearLayout is visible
                                  if ((event.getY() - downYValue) &lt; 0) {
                                      margin = ((event.getY() - downYValue)) / 2;
                                      ((CompanyInfoActivityNew) getActivity()).movePanel(margin);
                                  } else {
                                      v.onTouchEvent(event);
                                  }
                                  break;
  
                              case -230://linearLayout is invisible
                                  if ((event.getY() - downYValue) &gt; 0) {
                                      margin = ((event.getY() - downYValue)) / 2;
                                      ((CompanyInfoActivityNew) getActivity()).movePanel(margin);
                                  } else {
                                      v.onTouchEvent(event);
                                  }
                                  break;
  
                              default:
                                  if ((event.getY() - downYValue)&gt;=-230 &amp;&amp;(event.getY() - downYValue)&lt;=230  ) {
                                      margin = ((event.getY() - downYValue)) / 2;
                                      ((CompanyInfoActivityNew) getActivity()).movePanel(margin);
                                  }
                                  break;
                          }
                      }
                  }
              }
              return true;
          }
      });
  
  
  public void movePanel(double margin) {
      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) linearLayout1.getLayoutParams();
      int tempMargin = params.topMargin + (int) margin;
      if (tempMargin &lt;= 0 &amp;&amp; tempMargin &gt;= -210) {
          params.setMargins(0, tempMargin, 0, 0);
          linearLayout1.setLayoutParams(params);
      }
  }
  </code></pre>