android.support.v4.view.ViewCompat#offsetLeftAndRight ( )源码实例Demo

下面列出了android.support.v4.view.ViewCompat#offsetLeftAndRight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: letv   文件: ViewDragHelper.java
private void dragTo(int left, int top, int dx, int dy) {
    int clampedX = left;
    int clampedY = top;
    int oldLeft = this.mCapturedView.getLeft();
    int oldTop = this.mCapturedView.getTop();
    if (dx != 0) {
        clampedX = this.mCallback.clampViewPositionHorizontal(this.mCapturedView, left, dx);
        ViewCompat.offsetLeftAndRight(this.mCapturedView, clampedX - oldLeft);
    }
    if (dy != 0) {
        clampedY = this.mCallback.clampViewPositionVertical(this.mCapturedView, top, dy);
        ViewCompat.offsetTopAndBottom(this.mCapturedView, clampedY - oldTop);
    }
    if (dx != 0 || dy != 0) {
        this.mCallback.onViewPositionChanged(this.mCapturedView, clampedX, clampedY, clampedX - oldLeft, clampedY - oldTop);
    }
}
 
源代码2 项目: SwipeBack   文件: ViewDragHelper.java
private void dragTo(int left, int top, int dx, int dy) {
    int clampedX = left;
    int clampedY = top;
    final int oldLeft = mCapturedView.getLeft();
    final int oldTop = mCapturedView.getTop();
    if (dx != 0) {
        clampedX = mCallback.clampViewPositionHorizontal(mCapturedView, left, dx);
        ViewCompat.offsetLeftAndRight(mCapturedView, clampedX - oldLeft);
    }
    if (dy != 0) {
        clampedY = mCallback.clampViewPositionVertical(mCapturedView, top, dy);
        ViewCompat.offsetTopAndBottom(mCapturedView, clampedY - oldTop);
    }

    if (dx != 0 || dy != 0) {
        final int clampedDx = clampedX - oldLeft;
        final int clampedDy = clampedY - oldTop;
        mCallback.onViewPositionChanged(mCapturedView, clampedX, clampedY,
                clampedDx, clampedDy);
    }
}
 
源代码3 项目: star-zone-android   文件: ViewOffsetHelper.java
private void updateOffsets(boolean isTopAndBottom) {
    if (isTopAndBottom) {
        ViewCompat.offsetTopAndBottom(mTarget, mOffsetTop - mTarget.getTop());
    }else {
        ViewCompat.offsetLeftAndRight(mTarget, mOffsetLeft - mTarget.getLeft());
    }
}
 
源代码4 项目: letv   文件: ViewDragHelper.java
public boolean continueSettling(boolean deferCallbacks) {
    if (this.mDragState == 2) {
        boolean keepGoing = this.mScroller.computeScrollOffset();
        int x = this.mScroller.getCurrX();
        int y = this.mScroller.getCurrY();
        int dx = x - this.mCapturedView.getLeft();
        int dy = y - this.mCapturedView.getTop();
        if (dx != 0) {
            ViewCompat.offsetLeftAndRight(this.mCapturedView, dx);
        }
        if (dy != 0) {
            ViewCompat.offsetTopAndBottom(this.mCapturedView, dy);
        }
        if (!(dx == 0 && dy == 0)) {
            this.mCallback.onViewPositionChanged(this.mCapturedView, x, y, dx, dy);
        }
        if (keepGoing && x == this.mScroller.getFinalX() && y == this.mScroller.getFinalY()) {
            this.mScroller.abortAnimation();
            keepGoing = false;
        }
        if (!keepGoing) {
            if (deferCallbacks) {
                this.mParentView.post(this.mSetIdleRunnable);
            } else {
                setDragState(0);
            }
        }
    }
    return this.mDragState == 2;
}
 
源代码5 项目: UcMainPagerDemo   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
源代码9 项目: SpringHeader   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
源代码10 项目: ticdesign   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
源代码11 项目: SwipeBack   文件: ViewDragHelper.java
/**
 * Move the captured settling view by the appropriate amount for the current time.
 * If <code>continueSettling</code> returns true, the caller should call it again
 * on the next frame to continue.
 *
 * @param deferCallbacks true if state callbacks should be deferred via posted message.
 *                       Set this to true if you are calling this method from
 *                       {@link android.view.View#computeScroll()} or similar methods
 *                       invoked as part of layout or drawing.
 * @return true if settle is still in progress
 */
public boolean continueSettling(boolean deferCallbacks) {
    if (mDragState == STATE_SETTLING) {
        boolean keepGoing = mScroller.computeScrollOffset();
        final int x = mScroller.getCurrX();
        final int y = mScroller.getCurrY();
        final int dx = x - mCapturedView.getLeft();
        final int dy = y - mCapturedView.getTop();

        if (dx != 0) {
            ViewCompat.offsetLeftAndRight(mCapturedView, dx);
        }
        if (dy != 0) {
            ViewCompat.offsetTopAndBottom(mCapturedView, dy);
        }

        if (dx != 0 || dy != 0) {
            mCallback.onViewPositionChanged(mCapturedView, x, y, dx, dy);
        }

        if (keepGoing && x == mScroller.getFinalX() && y == mScroller.getFinalY()) {
            // Close enough. The interpolator/scroller might think we're still moving
            // but the user sure doesn't.
            mScroller.abortAnimation();
            keepGoing = false;
        }

        if (!keepGoing) {
            if (deferCallbacks) {
                mParentView.post(mSetIdleRunnable);
            } else {
                setDragState(STATE_IDLE);
            }
        }
    }

    return mDragState == STATE_SETTLING;
}
 
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
源代码13 项目: MyBlogDemo   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
源代码14 项目: UCMainViewForBehavior   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
源代码15 项目: BehaviorDemo   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
源代码16 项目: GpCollapsingToolbar   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
public void performUpdateViewPosition(int offset) {
    ViewCompat.offsetLeftAndRight(mRefreshContainerView,offset);
    ViewCompat.offsetLeftAndRight(mRecyclerView,offset);
    invalidate();
}
 
public void performUpdateViewPosition(int offset) {
    ViewCompat.offsetLeftAndRight(mRefreshContainerView, -offset);
    ViewCompat.offsetLeftAndRight(mRecyclerView, -offset);
    invalidate();
}
 
源代码19 项目: android-proguards   文件: ViewOffsetHelper.java
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
 同类方法