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


Java View.offsetLeftAndRight方法代码示例

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


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

示例1: parallaxOtherViews

import android.view.View; //导入方法依赖的package包/类
private void parallaxOtherViews(float slideOffset) {
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset &&
            (slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(dx);

        if (dimViews) {
            dimChildView(v,
                    1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
开发者ID:Jusenr,项目名称:RX_Demo,代码行数:23,代码来源:ResideLayout.java

示例2: resolveView

import android.view.View; //导入方法依赖的package包/类
/**
 * Updates View bounds, possibly re-measuring and re-layouting it if the size changed.
 *
 * @param reactTag reactTag to lookup a View by
 * @param left left coordinate relative to parent
 * @param top top coordinate relative to parent
 * @param right right coordinate relative to parent
 * @param bottom bottom coordinate relative to parent
 */
/* package */ void updateViewBounds(int reactTag, int left, int top, int right, int bottom) {
  View view = resolveView(reactTag);
  int width = right - left;
  int height = bottom - top;
  if (view.getWidth() != width || view.getHeight() != height) {
    // size changed, we need to measure and layout the View
    view.measure(
        MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(left, top, right, bottom);
  } else {
    // same size, only location changed, there is a faster route.
    view.offsetLeftAndRight(left - view.getLeft());
    view.offsetTopAndBottom(top - view.getTop());
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:26,代码来源:FlatNativeViewHierarchyManager.java

示例3: parallaxOtherViews

import android.view.View; //导入方法依赖的package包/类
private void parallaxOtherViews(float slideOffset) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset
            && (isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(isLayoutRtl ? -dx : dx);

        if (dimViews) {
            dimChildView(v, isLayoutRtl ? mParallaxOffset - 1
                    : 1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
开发者ID:zhudongya123,项目名称:WechatChatroomHelper,代码行数:24,代码来源:BGASwipeBackLayout.java

示例4: offsetChildToAnchor

import android.view.View; //导入方法依赖的package包/类
void offsetChildToAnchor(View child, int layoutDirection) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (lp.mAnchorView != null) {
        Rect anchorRect = this.mTempRect1;
        Rect childRect = this.mTempRect2;
        Rect desiredChildRect = this.mTempRect3;
        getDescendantRect(lp.mAnchorView, anchorRect);
        getChildRect(child, false, childRect);
        getDesiredAnchoredChildRect(child, layoutDirection, anchorRect, desiredChildRect);
        int dx = desiredChildRect.left - childRect.left;
        int dy = desiredChildRect.top - childRect.top;
        if (dx != 0) {
            child.offsetLeftAndRight(dx);
        }
        if (dy != 0) {
            child.offsetTopAndBottom(dy);
        }
        if (dx != 0 || dy != 0) {
            Behavior b = lp.getBehavior();
            if (b != null) {
                b.onDependentViewChanged(this, child, lp.mAnchorView);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:CoordinatorLayout.java

示例5: moveDrawerToOffset

import android.view.View; //导入方法依赖的package包/类
void moveDrawerToOffset(View drawerView, float slideOffset) {
  final float oldOffset = getDrawerViewOffset(drawerView);
  final int width = drawerView.getWidth();
  final int oldPos = (int) (width * oldOffset);
  final int newPos = (int) (width * slideOffset);
  final int dx = newPos - oldPos;

  drawerView.offsetLeftAndRight(
      checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT) ? dx : -dx);
  setDrawerViewOffset(drawerView, slideOffset);
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:12,代码来源:DebugDrawerLayout.java

示例6: offsetLeftAndRight

import android.view.View; //导入方法依赖的package包/类
static void offsetLeftAndRight(View view, int offset) {
    view.offsetLeftAndRight(offset);
    ViewParent parent = view.getParent();
    if (parent instanceof View) {
        tickleInvalidationFlag((View) parent);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:ViewCompatHC.java

示例7: moveSelection

import android.view.View; //导入方法依赖的package包/类
private View moveSelection(View oldSel, View newSel, int delta, int childrenLeft, int childrenRight) {
    View sel;
    int fadingEdgeLength = getHorizontalFadingEdgeLength();
    int selectedPosition = this.mSelectedPosition;
    int leftSelectionPixel = getLeftSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int rightSelectionPixel = getRightSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int halfHorizontalSpace;
    if (delta > 0) {
        oldSel = makeAndAddView(selectedPosition - 1, oldSel.getLeft(), true, this.mListPadding.top, false);
        int dividerWidth = this.mDividerWidth;
        sel = makeAndAddView(selectedPosition, oldSel.getRight() + dividerWidth, true, this.mListPadding.top, true);
        if (sel.getRight() > rightSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            int offset = Math.min(Math.min(sel.getLeft() - leftSelectionPixel, sel.getRight() - rightSelectionPixel), halfHorizontalSpace);
            oldSel.offsetLeftAndRight(-offset);
            sel.offsetLeftAndRight(-offset);
        }
        if (this.mStackFromRight) {
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
            adjustViewsLeftOrRight();
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
        } else {
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
            adjustViewsLeftOrRight();
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
        }
    } else if (delta < 0) {
        if (newSel != null) {
            sel = makeAndAddView(selectedPosition, newSel.getLeft(), true, this.mListPadding.top, true);
        } else {
            sel = makeAndAddView(selectedPosition, oldSel.getLeft(), false, this.mListPadding.top, true);
        }
        if (sel.getLeft() < leftSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            View view = sel;
            view.offsetLeftAndRight(Math.min(Math.min(leftSelectionPixel - sel.getLeft(), rightSelectionPixel - sel.getRight()), halfHorizontalSpace));
        }
        fillBeforeAndAfter(sel, selectedPosition);
    } else {
        int oldLeft = oldSel.getLeft();
        sel = makeAndAddView(selectedPosition, oldLeft, true, this.mListPadding.top, true);
        if (oldLeft < childrenLeft && sel.getRight() < childrenLeft + 20) {
            sel.offsetLeftAndRight(childrenLeft - sel.getLeft());
        }
        fillBeforeAndAfter(sel, selectedPosition);
    }
    return sel;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:49,代码来源:HListView.java

示例8: setupChild

import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (VERSION.SDK_INT >= 11) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
    if (needToMeasure) {
        int childWidthSpec;
        int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
        int lpWidth = p.width;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
        child.jumpDrawablesToCurrentState();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:65,代码来源:HListView.java

示例9: parallaxOtherViews

import android.view.View; //导入方法依赖的package包/类
private void parallaxOtherViews(float slideOffset) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset &&
            (isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        //////
        mBottomView = v;
        /////

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(isLayoutRtl ? -dx : dx);

        if (dimViews) {
            dimChildView(v, isLayoutRtl ? mParallaxOffset - 1 :
                    1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:28,代码来源:SideMenu.java

示例10: moveDrawerToOffset

import android.view.View; //导入方法依赖的package包/类
void moveDrawerToOffset(View drawerView, float slideOffset) {
    float oldOffset = getDrawerViewOffset(drawerView);
    int width = drawerView.getWidth();
    int dx = ((int) (((float) width) * slideOffset)) - ((int) (((float) width) * oldOffset));
    if (!checkDrawerViewAbsoluteGravity(drawerView, 3)) {
        dx = -dx;
    }
    drawerView.offsetLeftAndRight(dx);
    setDrawerViewOffset(drawerView, slideOffset);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:DrawerLayout.java

示例11: scrollLeft

import android.view.View; //导入方法依赖的package包/类
private int scrollLeft(int dx) {
    final int childCount = getChildCount();
    if (childCount == 0) {
        return 0;
    }

    final View lastView = getChildAt(childCount - 1);
    final boolean isLastItem = getPosition(lastView) == getItemCount() - 1;

    final int delta;
    if (isLastItem) {
        delta = Math.min(dx, getDecoratedRight(lastView) - activeCardRight);
    } else {
        delta = dx;
    }

    final int step = activeCardLeft / LEFT_CARD_COUNT;
    final int jDelta = (int) Math.ceil(1f * delta * step / cardWidth);

    for (int i = childCount - 1; i >= 0; i--) {
        final View view = getChildAt(i);
        final int viewLeft = getDecoratedLeft(view);

        if (viewLeft > activeCardLeft) {
            view.offsetLeftAndRight(getAllowedLeftDelta(view, delta, activeCardLeft));
        } else {
            int border = activeCardLeft - step;
            for (int j = i; j >= 0; j--) {
                final View jView = getChildAt(j);
                jView.offsetLeftAndRight(getAllowedLeftDelta(jView, jDelta, border));
                border -= step;
            }

            break;
        }
    }

    return delta;
}
 
开发者ID:Ramotion,项目名称:cardslider-android,代码行数:40,代码来源:CardSliderLayoutManager.java

示例12: repositionToWrapContentIfNecessary

import android.view.View; //导入方法依赖的package包/类
private void repositionToWrapContentIfNecessary() {
    if (this.mSecondaryOrientation.getMode() != 1073741824) {
        int i;
        View child;
        float maxSize = 0.0f;
        int childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            float size = (float) this.mSecondaryOrientation.getDecoratedMeasurement(child);
            if (size >= maxSize) {
                if (((LayoutParams) child.getLayoutParams()).isFullSpan()) {
                    size = (1.0f * size) / ((float) this.mSpanCount);
                }
                maxSize = Math.max(maxSize, size);
            }
        }
        int before = this.mSizePerSpan;
        int desired = Math.round(((float) this.mSpanCount) * maxSize);
        if (this.mSecondaryOrientation.getMode() == Integer.MIN_VALUE) {
            desired = Math.min(desired, this.mSecondaryOrientation.getTotalSpace());
        }
        updateMeasureSpecs(desired);
        if (this.mSizePerSpan != before) {
            for (i = 0; i < childCount; i++) {
                child = getChildAt(i);
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (!lp.mFullSpan) {
                    if (isLayoutRTL() && this.mOrientation == 1) {
                        child.offsetLeftAndRight(((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * this.mSizePerSpan) - ((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * before));
                    } else {
                        int newOffset = lp.mSpan.mIndex * this.mSizePerSpan;
                        int prevOffset = lp.mSpan.mIndex * before;
                        if (this.mOrientation == 1) {
                            child.offsetLeftAndRight(newOffset - prevOffset);
                        } else {
                            child.offsetTopAndBottom(newOffset - prevOffset);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:44,代码来源:StaggeredGridLayoutManager.java

示例13: onOffsetChild

import android.view.View; //导入方法依赖的package包/类
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) {
    child.offsetLeftAndRight(offsetLeft);
    child.offsetTopAndBottom(offsetTop);
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:5,代码来源:PLA_ListView.java

示例14: onPageScrolled

import android.view.View; //导入方法依赖的package包/类
@CallSuper
protected void onPageScrolled(int position, float offset, int offsetPixels) {
    int scrollX;
    int childCount;
    int i;
    View child;
    if (this.mDecorChildCount > 0) {
        scrollX = getScrollX();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int width = getWidth();
        childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.isDecor) {
                int childLeft;
                switch (lp.gravity & 7) {
                    case 1:
                        childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                        break;
                    case 3:
                        childLeft = paddingLeft;
                        paddingLeft += child.getWidth();
                        break;
                    case 5:
                        childLeft = (width - paddingRight) - child.getMeasuredWidth();
                        paddingRight += child.getMeasuredWidth();
                        break;
                    default:
                        childLeft = paddingLeft;
                        break;
                }
                int childOffset = (childLeft + scrollX) - child.getLeft();
                if (childOffset != 0) {
                    child.offsetLeftAndRight(childOffset);
                }
            }
        }
    }
    dispatchOnPageScrolled(position, offset, offsetPixels);
    if (this.mPageTransformer != null) {
        scrollX = getScrollX();
        childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            if (!((LayoutParams) child.getLayoutParams()).isDecor) {
                this.mPageTransformer.transformPage(child, ((float) (child.getLeft() - scrollX)) / ((float) getClientWidth()));
            }
        }
    }
    this.mCalledSuper = true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:54,代码来源:ViewPager.java

示例15: parallaxOtherViews

import android.view.View; //导入方法依赖的package包/类
private void parallaxOtherViews(float slideOffset) {
    boolean dimViews;
    int childCount;
    int i;
    View v;
    int dx;
    boolean isLayoutRtl = isLayoutRtlSupport();
    LayoutParams slideLp = (LayoutParams) this.mSlideableView.getLayoutParams();
    if (slideLp.dimWhenOffset) {
        if ((isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0) {
            dimViews = true;
            childCount = getChildCount();
            for (i = 0; i < childCount; i++) {
                v = getChildAt(i);
                if (v == this.mSlideableView) {
                    int oldOffset = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
                    this.mParallaxOffset = slideOffset;
                    dx = oldOffset - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
                    if (isLayoutRtl) {
                        dx = -dx;
                    }
                    v.offsetLeftAndRight(dx);
                    if (!dimViews) {
                        dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
                    }
                }
            }
        }
    }
    dimViews = false;
    childCount = getChildCount();
    for (i = 0; i < childCount; i++) {
        v = getChildAt(i);
        if (v == this.mSlideableView) {
            int oldOffset2 = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
            this.mParallaxOffset = slideOffset;
            dx = oldOffset2 - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
            if (isLayoutRtl) {
                dx = -dx;
            }
            v.offsetLeftAndRight(dx);
            if (!dimViews) {
                if (isLayoutRtl) {
                }
                dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:50,代码来源:SlidingPaneLayout.java


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