notifyDataSetChanged() refresh the whole layout
<p>I didn't describe the question in a good way, so I edit the question to be clear.</p>

<p>I am so confused about this: I wrote a <strong>RelativeLayout</strong> with a <strong>DragViewGroup</strong> and a <strong>gridview</strong>, and I noticed that every time when I used <strong>notifyDatasetChanged()</strong> method would cause the <strong>DragViewGroup</strong> do the redrawing thing.And the <strong>DragViewGroup</strong> extends from <strong>LinearLayout</strong> which uses <strong>ViewDragHelper</strong>, so I could not maintain the position already scrolled to. </p>

<p>Here is my xml file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"&gt;
&lt;com.xxxx.DragViewGroup
    android:id="@+id/dragview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#3f83f7"
    android:orientation="vertical"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="665dp"
        android:orientation="vertical"&gt;
        &lt;RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="310dp"
            android:id="@+id/mainview"
            &gt;

            ...

        &lt;/RelativeLayout&gt;

        &lt;include
            android:layout_width="match_parent"
            android:layout_height="355dp"
            android:layout_marginBottom="62dp"
            layout="@layout/fake_panel" /&gt;

    &lt;/LinearLayout&gt;
&lt;/com.xxxx.DragViewGroup&gt;
&lt;RelativeLayout
    android:layout_width="match_parent"
    android:id="@+id/layout"
    android:layout_alignParentBottom="true"
    android:layout_height="210dp"
    android:background="#ffffff"
    android:clickable="true"
    &gt;

    &lt;HorizontalScrollView
        android:id="@+id/btn_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:overScrollMode="never"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="26dp"
        android:scrollbars="none"&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;

            &lt;GridView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="10dp"
                android:listSelector="@color/transparent"
                android:horizontalSpacing="6dp"
                android:scrollbars="none" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/HorizontalScrollView&gt;

    &lt;com.xxxx.UniversalSeekBar
        ....
        android:layout_marginTop="18dp"/&gt;
&lt;/RelativeLayout&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>DragViewGroup code:</p>

<pre><code>public class DragViewGroup extends LinearLayout {
     private ViewDragHelper viewDragHelper;
     private View mainView;
     private int mainHeight;



public DragViewGroup(Context context) {
    super(context);
    initView();
}

public DragViewGroup(Context context, AttributeSet attrs) {
    super(context, attrs);
    initView();
}

public DragViewGroup(Context context, AttributeSet attrs, int defStyleAttr)         {
    super(context, attrs, defStyleAttr);
    initView();
}

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mainView = getChildAt(0);
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mainHeight = mainView.findViewById(R.id.mainview).getMeasuredHeight();
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    return viewDragHelper.shouldInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    viewDragHelper.processTouchEvent(event);
    return true;
}

@Override
public void computeScroll() {
    if (viewDragHelper.continueSettling(true)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

private void initView() {
    viewDragHelper = ViewDragHelper.create(this, callback);
}

private ViewDragHelper.Callback callback = new ViewDragHelper.Callback() {
    @Override
    public boolean tryCaptureView(View child, int pointerId) {
        return mainView == child;
    }

    @Override
    public int clampViewPositionHorizontal(View child, int left, int dx) {
        return 0;
    }

    @Override
    public int clampViewPositionVertical(View child, int top, int dy) {
        return top;
    }

    @Override
    public void onViewReleased(View releasedChild, float xvel, float yvel) {
        super.onViewReleased(releasedChild, xvel, yvel);
        if (mainView.getTop() &gt; -500) {
            viewDragHelper.smoothSlideViewTo(mainView, 0, 0);
            ViewCompat.postInvalidateOnAnimation(DragViewGroup.this);

        } else {
            viewDragHelper.smoothSlideViewTo(mainView, 0, -mainHeight);
            ViewCompat.postInvalidateOnAnimation(DragViewGroup.this);

        }
    }

};

}
</code></pre>

<p>Once I use the notifyDatasetChanged() method to update the gridview, my DragViewGroup will slide to the original position itself although it has been dragged before. Apparently the method draw the whole layout instead of only drawing gridview itself.</p>

<p>I need to maintain the dragged position of DragViewGroup, I have tried that override onDraw method in DragViewGroup like this:</p>

<pre><code>@Override
protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   // set isDragged label in onViewReleased()   
   if (isDragged) {
      viewDragHelper.smoothSlideViewTo(main, 0, -mainHeight);
   }
}
</code></pre>

<p>It works, but there is a visible sliding process which I don't want.
Hope someone could help me.Thanks very much.</p>