Java Code Examples for android.view.View.offsetTopAndBottom()

The following are Jave code examples for showing how to use offsetTopAndBottom() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OpenWithX   File: ResolverDrawerLayout.java   Source Code and License Vote up 6 votes
private float performDrag(float dy) {
    final float newPos = Math.max(0, Math.min(mCollapseOffset + dy,
            mCollapsibleHeight + mUncollapsibleHeight));
    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);
            }
        }
        final boolean isCollapsedOld = mCollapseOffset != 0;
        mCollapseOffset = newPos;
        mTopOffset += dy;
        final boolean isCollapsedNew = newPos != 0;
        if (isCollapsedOld != isCollapsedNew) {
            onCollapsedChanged(isCollapsedNew);
        }
        postInvalidateOnAnimation();
        return dy;
    }
    return 0;
}
 
Example 2
Project: SwipeCard-   File: SwipeFlingAdapterView.java   Source Code and License Vote up 6 votes
private void adjustChildrenOfUnderTopView(float scrollRate) {
    int count = getChildCount();
    if (count > 1) {
        int i;
        int multiple;
        if (count == 2) {
            i = LAST_OBJECT_IN_STACK - 1;
            multiple = 1;
        } else {
            i = LAST_OBJECT_IN_STACK - 2;
            multiple = 2;
        }
        float rate = Math.abs(scrollRate);
        for (; i < LAST_OBJECT_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);
        }
    }
}
 
Example 3
Project: AssistantBySDK   File: LingjuSwipeUpLoadRefreshLayout.java   Source Code and License Vote up 6 votes
private void setTargetOffsetTopAndBottom(View target, int offset, boolean requiresUpdate) {
    target.bringToFront();
    //Log.e(TAG, "setTargetOffsetTopAndBottom>>target.getTop="+target.getTop());
    target.offsetTopAndBottom(offset);
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>bCircleView,offset="+offset+",top="+target.getTop());
        bCurrentTargetOffsetTop = target.getTop();
    if (requiresUpdate && android.os.Build.VERSION.SDK_INT < 11) {
        invalidate();
    }
}
 
Example 4
Project: Bridge   File: ResolverDrawerLayout.java   Source Code and License Vote up 6 votes
private float performDrag(float dy) {
    final float newPos = Math.max(0, Math.min(mCollapseOffset + dy,
            mCollapsibleHeight + mUncollapsibleHeight));
    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);
            }
        }
        final boolean isCollapsedOld = mCollapseOffset != 0;
        mCollapseOffset = newPos;
        mTopOffset += dy;
        final boolean isCollapsedNew = newPos != 0;
        if (isCollapsedOld != isCollapsedNew) {
            onCollapsedChanged(isCollapsedNew);
        }
        postInvalidateOnAnimation();
        return dy;
    }
    return 0;
}
 
Example 5
Project: RNLearn_Project1   File: FlatNativeViewHierarchyManager.java   Source Code and License Vote up 6 votes
/**
 * 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());
  }
}
 
Example 6
Project: RNLearn_Project1   File: FlatNativeViewHierarchyManager.java   Source Code and License Vote up 6 votes
/**
 * 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());
  }
}
 
Example 7
Project: boohee_v5.6   File: CoordinatorLayout.java   Source Code and License Vote up 6 votes
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);
            }
        }
    }
}
 
Example 8
Project: SwipeCard-   File: SwipeFlingAdapterView.java   Source Code and License Vote up 5 votes
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);
    }
}
 
Example 9
Project: AssistantBySDK   File: LingjuSwipeRefreshLayout.java   Source Code and License Vote up 5 votes
private void setTargetOffsetTopAndBottom(View target, int offset, boolean requiresUpdate) {
    target.bringToFront();
    //Log.e(TAG, "setTargetOffsetTopAndBottom>>target.getTop="+target.getTop());
    target.offsetTopAndBottom(offset);
    if (target == tCircleView) {
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>tCircleView,offset="+offset+",top="+target.getTop());
        tCurrentTargetOffsetTop = target.getTop();
    } else {
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>bCircleView,offset="+offset+",top="+target.getTop());
        bCurrentTargetOffsetTop = target.getTop();
    }
    if (requiresUpdate && android.os.Build.VERSION.SDK_INT < 11) {
        invalidate();
    }
}
 
Example 10
Project: letv   File: HListView.java   Source Code and License Vote up 5 votes
@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();
    }
}
 
Example 11
Project: letv   File: ViewCompatBase.java   Source Code and License Vote up 5 votes
static void offsetTopAndBottom(View view, int offset) {
    int currentTop = view.getTop();
    view.offsetTopAndBottom(offset);
    if (offset != 0) {
        ViewParent parent = view.getParent();
        if (parent instanceof View) {
            int absOffset = Math.abs(offset);
            ((View) parent).invalidate(view.getLeft(), currentTop - absOffset, view.getRight(), (view.getHeight() + currentTop) + absOffset);
            return;
        }
        view.invalidate();
    }
}
 
Example 12
Project: letv   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
static void offsetTopAndBottom(View view, int offset) {
    view.offsetTopAndBottom(offset);
    ViewParent parent = view.getParent();
    if (parent instanceof View) {
        tickleInvalidationFlag((View) parent);
    }
}
 
Example 13
Project: boohee_v5.6   File: MultiColumnListView.java   Source Code and License Vote up 5 votes
public void offsetTopAndBottom(int offset) {
    if (offset != 0) {
        int childCount = MultiColumnListView.this.getChildCount();
        for (int index = 0; index < childCount; index++) {
            View v = MultiColumnListView.this.getChildAt(index);
            if (v.getLeft() == this.mColumnLeft || MultiColumnListView.this.isFixedView
                    (v)) {
                v.offsetTopAndBottom(offset);
            }
        }
    }
}
 
Example 14
Project: Swap   File: PLA_AbsListView.java   Source Code and License Vote up 5 votes
protected void tryOffsetChildrenTopAndBottom(int offset) {
    final int count = getChildCount();

    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);
        v.offsetTopAndBottom(offset);
    }
}
 
Example 15
Project: boohee_v5.6   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
static void offsetTopAndBottom(View view, int offset) {
    view.offsetTopAndBottom(offset);
    ViewParent parent = view.getParent();
    if (parent instanceof View) {
        tickleInvalidationFlag((View) parent);
    }
}
 
Example 16
Project: CSipSimple   File: ActionBarContainer.java   Source Code and License Vote up 4 votes
@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();
    }
}
 
Example 17
Project: letv   File: ViewCompatMarshmallow.java   Source Code and License Vote up 4 votes
static void offsetTopAndBottom(View view, int offset) {
    view.offsetTopAndBottom(offset);
}
 
Example 18
Project: boohee_v5.6   File: PLA_ListView.java   Source Code and License Vote up 4 votes
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) {
    child.offsetLeftAndRight(offsetLeft);
    child.offsetTopAndBottom(offsetTop);
}
 
Example 19
Project: boohee_v5.6   File: StaggeredGridLayoutManager.java   Source Code and License Vote up 4 votes
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);
                        }
                    }
                }
            }
        }
    }
}
 
Example 20
Project: Swap   File: PLA_ListView.java   Source Code and License Vote up 4 votes
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) {
    child.offsetLeftAndRight(offsetLeft);
    child.offsetTopAndBottom(offsetTop);
}