android.view.View#offsetTopAndBottom ( )源码实例Demo

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

private float performDrag(float dy) {
    final float newPos = Math.max(0, Math.min(mCollapseOffset + dy, mCollapsibleHeight));
    if (newPos != mCollapseOffset) {
        dy = newPos - mCollapseOffset;
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.ignoreOffset) {
                child.offsetTopAndBottom((int) dy);
            }
        }
        mCollapseOffset = newPos;
        mTopOffset += dy;
        ViewCompat.postInvalidateOnAnimation(this);
        return dy;
    }
    return 0;
}
 
源代码2 项目: UltimateAndroid   文件: StaggeredGridView.java
protected void offsetChildrenTopAndBottom(final int offset, final int column) {
    if (DBG) Log.d(TAG, "offsetChildrenTopAndBottom: " + offset + " column:" + column);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);
        if (v != null &&
                v.getLayoutParams() != null &&
                v.getLayoutParams() instanceof GridLayoutParams) {
            GridLayoutParams lp = (GridLayoutParams) v.getLayoutParams();
            if (lp.column == column) {
                v.offsetTopAndBottom(offset);
            }
        }
    }
    offsetColumnTopAndBottom(offset, column);
}
 
源代码3 项目: EverMemo   文件: MultiColumnListView.java
public void offsetTopAndBottom(int offset) {
	if( offset == 0 )
		return; 

	//find biggest value.
	int childCount = getChildCount();

	for( int index = 0; index < childCount; ++index ){
		View v = getChildAt(index);

		if(v.getLeft() != mColumnLeft && isFixedView(v) == false )
			continue;

		v.offsetTopAndBottom(offset);
	}
}
 
源代码4 项目: SwipeAdapterView   文件: SwipeAdapterView.java
private void adjustChildrenOfUnderTopView(float scrollRate) {
    int count = getChildCount();
    if (count > 1) {
        int i;
        int multiple;
        if (count == 2) {
            i = LAST_VIEW_IN_STACK - 1;
            multiple = 1;
        } else {
            i = LAST_VIEW_IN_STACK - 2;
            multiple = 2;
        }
        float rate = Math.abs(scrollRate);
        for (; i < LAST_VIEW_IN_STACK; i++, multiple--) {
            View underTopView = getChildAt(i);
            int offset = (int) (yOffsetStep * (multiple - rate));
            underTopView.offsetTopAndBottom(offset - underTopView.getTop() + initTop);
            underTopView.setScaleX(1 - SCALE_STEP * multiple + SCALE_STEP * rate);
            underTopView.setScaleY(1 - SCALE_STEP * multiple + SCALE_STEP * rate);
        }
    }
}
 
源代码5 项目: SlidingUpPaneLayout   文件: SlidingUpPaneLayout.java
private void parallaxOtherViews(float slideOffset) {
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset &&
            slideLp.topMargin <= 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 dy = oldOffset - newOffset;

        v.offsetTopAndBottom(dy);

        if (dimViews) {
            dimChildView(v, 1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
源代码6 项目: ZrcListView   文件: ZrcAbsListView.java
public void offsetChildrenTopAndBottom(int offset) {
	final int count = getChildCount();
	for (int i = 0; i < count; i++) {
		final View v = getChildAt(i);
		v.offsetTopAndBottom(offset);
	}
}
 
源代码7 项目: UltimateAndroid   文件: ExtendableListView.java
protected void offsetChildrenTopAndBottom(int offset) {
    if (DBG) Log.d(TAG, "offsetChildrenTopAndBottom: " + offset);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);
        v.offsetTopAndBottom(offset);
    }
}
 
源代码8 项目: SwipeAdapterView   文件: SwipeAdapterView.java
private void adjustChildView(View child, int index) {
    if (index > -1 && index < MAX_VISIBLE) {
        int multiple;
        if (index > 2) multiple = 2;
        else multiple = index;
        child.offsetTopAndBottom(yOffsetStep * multiple);
        child.setScaleX(1 - SCALE_STEP * multiple);
        child.setScaleY(1 - SCALE_STEP * multiple);
    }
}
 
源代码9 项目: Social   文件: SwipeFlingAdapterView.java
/**
 * 跳转改变view 大小
 *
 * @param child
 * @param index
 */
private void adjustChildView(View child, int index) {
    int n;
    if (index > 1)
        n = 2;
    else
        n = index;
    if (index == 3 && p > 0.5f) {
        n = index;
    }
    child.offsetTopAndBottom((int) (dpToPx((int) ITEM_SMALL_HIGH) * (n - p)));
    child.setScaleX(1 - 0.1f * (n - p));
    child.setScaleY(1 - 0.1f * (n - p));
}
 
源代码10 项目: flickr-uploader   文件: SlidingDrawer.java
private void moveHandle(int position) {
	final View handle = mHandle;

	if (position == EXPANDED_FULL_OPEN) {
		handle.offsetTopAndBottom(mTopOffset - handle.getTop());
		invalidate();
	} else if (position == COLLAPSED_FULL_CLOSED) {
		handle.offsetTopAndBottom(mBottomOffset + getBottom() - getTop() - mHandleHeight - handle.getTop());
		invalidate();
	} else {
		final int top = handle.getTop();
		int deltaY = position - top;
		if (position < mTopOffset) {
			deltaY = mTopOffset - top;
		} else if (deltaY > mBottomOffset + getBottom() - getTop() - mHandleHeight - top) {
			deltaY = mBottomOffset + getBottom() - getTop() - mHandleHeight - top;
		}
		handle.offsetTopAndBottom(deltaY);

		final Rect frame = mFrame;
		final Rect region = mInvalidate;

		handle.getHitRect(frame);
		region.set(frame);

		region.union(frame.left, frame.top - deltaY, frame.right, frame.bottom - deltaY);
		region.union(0, frame.bottom - deltaY, getWidth(), frame.bottom - deltaY + mContent.getHeight());

		invalidate(region);
	}
}
 
源代码11 项目: Lay-s   文件: PLAAbsListView.java
protected void tryOffsetChildrenTopAndBottom(int offset) {
    final int count = getChildCount();

    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);
        v.offsetTopAndBottom(offset);
    }
}
 
源代码12 项目: ticdesign   文件: CoordinatorLayout.java
/**
 * Adjust the child left, top, right, bottom rect to the correct anchor view position,
 * respecting gravity and anchor gravity.
 *
 * Note that child translation properties are ignored in this process, allowing children
 * to be animated away from their anchor. However, if the anchor view is animated,
 * the child will be offset to match the anchor's translated position.
 */
void offsetChildToAnchor(View child, int layoutDirection) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (lp.mAnchorView != null) {
        final Rect anchorRect = mTempRect1;
        final Rect childRect = mTempRect2;
        final Rect desiredChildRect = mTempRect3;

        getDescendantRect(lp.mAnchorView, anchorRect);
        getChildRect(child, false, childRect);
        getDesiredAnchoredChildRect(child, layoutDirection, anchorRect, desiredChildRect);

        final int dx = desiredChildRect.left - childRect.left;
        final int dy = desiredChildRect.top - childRect.top;

        if (dx != 0) {
            child.offsetLeftAndRight(dx);
        }
        if (dy != 0) {
            child.offsetTopAndBottom(dy);
        }

        if (dx != 0 || dy != 0) {
            // If we have needed to move, make sure to notify the child's Behavior
            final Behavior b = lp.getBehavior();
            if (b != null) {
                b.onDependentViewChanged(this, child, lp.mAnchorView);
            }
        }
    }
}
 
源代码13 项目: Lay-s   文件: PLAListView.java
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) {
    child.offsetLeftAndRight(offsetLeft);
    child.offsetTopAndBottom(offsetTop);
}
 
源代码14 项目: pius1   文件: SlideBottomPanel.java
private void handleActionMove(MotionEvent event) {
    if (!isPanelOnTouch) {
        return;
    }
    if (isPanelShowing && supportScrollInView((int) (firstDownY - event.getY()))) {
        return;
    }
    computeVelocity();
    if (Math.abs(xVelocity) > Math.abs(yVelocity)) {
        return;
    }
    if (!isDragging && Math.abs(event.getY() - firstDownY) > mTouchSlop
            && Math.abs(event.getX() - firstDownX) < mTouchSlop) {
        isDragging = true;
        downY = event.getY();
    }
    if (isDragging) {
        deltaY = event.getY() - downY;
        downY = event.getY();

        View touchingView = findViewWithTag(TAG_PANEL);

        if (mHidePanelTitle && isPanelShowing) {
            hidePanelTitle(touchingView);
        }

        if (mDarkFrameLayout != null && mIsFade) {
            float currentY = ViewHelper.getY(touchingView);
            if (currentY > mMeasureHeight - mPanelHeight &&
                    currentY < mMeasureHeight - mTitleHeightNoDisplay) {
                mDarkFrameLayout.fade(
                        (int) ((1 - currentY / (mMeasureHeight - mTitleHeightNoDisplay)) * DarkFrameLayout.MAX_ALPHA));
            }
        }
        if (!mBoundary) {
            touchingView.offsetTopAndBottom((int) deltaY);
        } else {
            float touchingViewY = ViewHelper.getY(touchingView);
            if (touchingViewY + deltaY <= mMeasureHeight - mPanelHeight) {
                touchingView.offsetTopAndBottom((int) (mMeasureHeight - mPanelHeight - touchingViewY));
            } else if (touchingViewY + deltaY >= mMeasureHeight - mTitleHeightNoDisplay) {
                touchingView.offsetTopAndBottom((int) (mMeasureHeight - mTitleHeightNoDisplay - touchingViewY));
            } else {
                touchingView.offsetTopAndBottom((int) deltaY);
            }
        }
    }
}
 
源代码15 项目: MiBandDecompiled   文件: ParallaxScrollView.java
protected void translatePreICS(View view, float f1)
{
    view.offsetTopAndBottom((int)f1 - lastOffset);
    lastOffset = (int)f1;
}
 
源代码16 项目: CSipSimple   文件: ActionBarContainer.java
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
源代码17 项目: letv   文件: HListView.java
@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();
    }
}
 
源代码18 项目: ParallaxScroll   文件: ParallaxScrollView.java
@Override
protected void translatePreICS(View view, float offset) {
	view.offsetTopAndBottom((int)offset - lastOffset);
	lastOffset = (int)offset;
}
 
protected void translatePreICS(View view, float f)
{
    view.offsetTopAndBottom((int)f - lastOffset);
    lastOffset = (int)f;
}
 
源代码20 项目: material   文件: BottomSheetDialog.java
public void setChildTop(int top){
    mChildTop = top;
    View child = getChildAt(0);
    if(child != null)
        child.offsetTopAndBottom(mChildTop - child.getTop());
}
 
 方法所在类
 同类方法