当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.offsetLeftAndRight方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.offsetLeftAndRight方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.offsetLeftAndRight方法的具体用法?Java ViewCompat.offsetLeftAndRight怎么用?Java ViewCompat.offsetLeftAndRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.offsetLeftAndRight方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dragTo

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void dragTo(int left, int top, int dx, int dy) {
    int clampedX = left;
    int clampedY = top;
    final int oldLeft = (int) mCapturedView.getX();
    final int oldTop = (int) mCapturedView.getY();
    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);
    }
}
 
开发者ID:Kaufland,项目名称:andswipeframework,代码行数:22,代码来源:KDragViewHelper.java

示例2: dragTo

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:ViewDragHelper.java

示例3: onLayoutChild

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, StretchView child, int layoutDirection) {
    if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) {
        ViewCompat.setFitsSystemWindows(child, true);
    }
    parent.onLayoutChild(child, layoutDirection);
    //设置起始位置
    switch (child.getDirection()) {
        case StretchView.LEFT:
            ViewCompat.offsetLeftAndRight(child, -child.getWidth() + mTranslation);
            break;
        case StretchView.RIGHT:
            ViewCompat.offsetLeftAndRight(child, parent.getWidth() - child.getLeft() - parent.getPaddingRight() + mTranslation);
            break;
        case StretchView.BOTTOM:
            ViewCompat.offsetTopAndBottom(child, parent.getHeight() - child.getTop() - parent.getPaddingBottom() + mTranslation);
            break;
    }
    return true;
}
 
开发者ID:thunderpunch,项目名称:StretchView,代码行数:21,代码来源:StretchView.java

示例4: continueSettling

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * 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 = (int) (x - mCapturedView.getX());
        final int dy = (int) (y - mCapturedView.getY());

        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;
}
 
开发者ID:Kaufland,项目名称:andswipeframework,代码行数:49,代码来源:KDragViewHelper.java

示例5: continueSettling

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:31,代码来源:ViewDragHelper.java

示例6: setInsetOffsetX

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void setInsetOffsetX(View child, int offsetX) {
  final LayoutParams lp = (LayoutParams) child.getLayoutParams();
  if (lp.mInsetOffsetX != offsetX) {
    final int dx = offsetX - lp.mInsetOffsetX;
    ViewCompat.offsetLeftAndRight(child, dx);
    lp.mInsetOffsetX = offsetX;
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:9,代码来源:CoordinatorLayout.java

示例7: onLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (mFunKeyCount > 0) {
        // 位移删除键
        ViewCompat.offsetLeftAndRight(getChildAt(mFunKeyIndex), mWidthUnused);
        if (mFunKeyCount == 2) {
            // 位移确定键
            ViewCompat.offsetLeftAndRight(getChildAt(mFunKeyIndex + 1), mWidthUnused + (mFunKeySpace - mGeneralKeySpace));
        }
    }
}
 
开发者ID:parkingwang,项目名称:vehicle-keyboard-android,代码行数:13,代码来源:KeyRowLayout.java

示例8: offsetIfNeeded

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Pre-Lollipop we use padding so that the shadow has enough space to be drawn. This method
     * offsets our layout position so that we're positioned correctly if we're on one of
     * our parent's edges.
 */
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
  final Rect padding = fab.mShadowPadding;

  if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) fab.getLayoutParams();

    int offsetTB = 0, offsetLR = 0;

    if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
      // If we're on the right edge, shift it the right
      offsetLR = padding.right;
    } else if (fab.getLeft() <= lp.leftMargin) {
      // If we're on the left edge, shift it the left
      offsetLR = -padding.left;
    }
    if (fab.getBottom() >= parent.getHeight() - lp.bottomMargin) {
      // If we're on the bottom edge, shift it down
      offsetTB = padding.bottom;
    } else if (fab.getTop() <= lp.topMargin) {
      // If we're on the top edge, shift it up
      offsetTB = -padding.top;
    }

    if (offsetTB != 0) {
      ViewCompat.offsetTopAndBottom(fab, offsetTB);
    }
    if (offsetLR != 0) {
      ViewCompat.offsetLeftAndRight(fab, offsetLR);
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:38,代码来源:FloatingActionButton.java

示例9: updateOffsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:14,代码来源:ViewOffsetHelper.java

示例10: updateOffsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
开发者ID:coopese,项目名称:qmui,代码行数:5,代码来源:QMUIViewOffsetHelper.java

示例11: updateOffsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateOffsets() 
{
       ViewCompat.offsetTopAndBottom(this.view, this.offsetTop - (this.view.getTop() - this.layoutTop));
       ViewCompat.offsetLeftAndRight(this.view, this.offsetLeft - (this.view.getLeft() - this.layoutLeft));
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:6,代码来源:ViewOffsetHelper.java

示例12: updateOffsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateOffsets() 
{
       ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
       ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:6,代码来源:ViewOffsetHelper.java

示例13: updateOffsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateOffsets() {
  ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
  ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:5,代码来源:ViewOffsetHelper.java

示例14: offsetChildrenLeftAndRight

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void offsetChildrenLeftAndRight(int delta){
    ViewCompat.offsetLeftAndRight(mMainView,delta);
    ViewCompat.offsetLeftAndRight(mSideView,delta);
}
 
开发者ID:AndroidBoySC,项目名称:Mybilibili,代码行数:5,代码来源:SwipeItemLayout.java


注:本文中的android.support.v4.view.ViewCompat.offsetLeftAndRight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。