The workaround I'm using is to record the view's offsets after each drag operation, and reapply them in onLayout()
, e.g.
View mVdhView;
int mVdhXOffset;
int mVdhYOffset;
@Override
public void computeScroll() {
if (dragHelper.continueSettling(true)) {
postInvalidateOnAnimation();
} else {
mVdhXOffset = mVdhView.getLeft();
mVdhYOffset = mVdhView.getTop();
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
// Reapply VDH offsets
mVdhView.offsetLeftAndRight(mVdhXOffset);
mVdhView.offsetTopAndBottom(mVdhYOffset);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…