Java Code Examples for android.view.View#offsetLeftAndRight()
The following examples show how to use
android.view.View#offsetLeftAndRight() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ResideLayout File: ResideLayout.java License: Apache License 2.0 | 6 votes |
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); } } }
Example 2
Source Project: letv File: HListView.java License: Apache License 2.0 | 6 votes |
private View fillFromMiddle(int childrenLeft, int childrenRight) { int width = childrenRight - childrenLeft; int position = reconcileSelectedPosition(); View sel = makeAndAddView(position, childrenLeft, true, this.mListPadding.top, true); this.mFirstPosition = position; int selWidth = sel.getMeasuredWidth(); if (selWidth <= width) { sel.offsetLeftAndRight((width - selWidth) / 2); } fillBeforeAndAfter(sel, position); if (this.mStackFromRight) { correctTooSmall(getChildCount()); } else { correctTooWide(getChildCount()); } return sel; }
Example 3
Source Project: KlyphMessenger File: SlidingPaneLayout.java License: MIT License | 6 votes |
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); } } }
Example 4
Source Project: support File: DrawerFrameV2.java License: Apache License 2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child.getVisibility() == GONE) continue; final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (child.getId() == R.id.menu) { final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); int childLeft = 0; child.layout(childLeft, lp.topMargin, childLeft + childWidth, lp.topMargin + childHeight); child.offsetLeftAndRight(-mLeftViewWidth); } else if (child.getId() == R.id.main) { child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight()); } } }
Example 5
Source Project: CodenameOne File: DrawerLayout.java License: GNU General Public License v2.0 | 5 votes |
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(checkDrawerViewGravity(drawerView, Gravity.LEFT) ? dx : -dx); setDrawerViewOffset(drawerView, slideOffset); }
Example 6
Source Project: u2020 File: DebugDrawerLayout.java License: Apache License 2.0 | 5 votes |
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); }
Example 7
Source Project: SmartSwipe File: ViewCompat.java License: Apache License 2.0 | 5 votes |
/** * Offset this view's horizontal location by the specified amount of pixels. * * @param view view * @param offset the number of pixels to offset the view by */ public static void offsetLeftAndRight(View view, int offset) { if (view == null || offset == 0) { return; } if (Build.VERSION.SDK_INT >= 23) { view.offsetLeftAndRight(offset); } else if (Build.VERSION.SDK_INT >= 21) { final Rect parentRect = getEmptyTempRect(); boolean needInvalidateWorkaround = false; final ViewParent parent = view.getParent(); if (parent instanceof View) { final View p = (View) parent; parentRect.set(p.getLeft(), p.getTop(), p.getRight(), p.getBottom()); // If the view currently does not currently intersect the parent (and is therefore // not displayed) we may need need to invalidate needInvalidateWorkaround = !parentRect.intersects(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); } // Now offset, invoking the API 14+ implementation (which contains its own workarounds) compatOffsetLeftAndRight(view, offset); // The view has now been offset, so let's intersect the Rect and invalidate where // the View is now displayed if (needInvalidateWorkaround && parentRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) { ((View) parent).invalidate(parentRect); } } else { compatOffsetLeftAndRight(view, offset); } }
Example 8
Source Project: MiBandDecompiled File: DrawerLayout.java License: Apache License 2.0 | 5 votes |
void c(View view, float f1) { float f2 = c(view); int i1 = view.getWidth(); int j1 = (int)(f2 * (float)i1); int k1 = (int)(f1 * (float)i1) - j1; if (!a(view, 3)) { k1 = -k1; } view.offsetLeftAndRight(k1); b(view, f1); }
Example 9
Source Project: something.apk File: MarginDrawerLayout.java License: MIT License | 5 votes |
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); }
Example 10
Source Project: MonthView File: MonthTitleView.java License: Apache License 2.0 | 5 votes |
protected void makeAndAddCellView(int left, int top, int index) { final boolean recycled = !scrapTitleViews.isEmpty(); final View child = recycled ? (scrapTitleViews.remove(0)) : (adapter.createTitleView(this)); adapter.bindTitleView(child, index); LayoutParams lp = child.getLayoutParams(); if(lp == null){ lp = new LayoutParams(titleWidth, titleHeight); } if(recycled){ attachViewToParent(child, index, lp); }else{ addViewInLayout(child, index, lp, true); } final boolean needToMeasure = !recycled || child.isLayoutRequested(); if (needToMeasure) { final int childWidthSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(titleWidth, MeasureSpec.EXACTLY), 0, lp.width); final int childHeightSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(titleHeight, MeasureSpec.EXACTLY), 0, lp.height); child.measure(childWidthSpec, childHeightSpec); } else { cleanupLayoutState(child); } if (needToMeasure) { child.layout(left, top,left + titleWidth, top + titleHeight); } else { child.offsetLeftAndRight(left - child.getLeft()); child.offsetTopAndBottom(top - child.getTop()); } }
Example 11
Source Project: ProjectX File: BothDirectionsScrollLayoutManager.java License: Apache License 2.0 | 5 votes |
@Override public void layoutDecorated(@NonNull View child, int left, int top, int right, int bottom) { super.layoutDecorated(child, left, top, right, bottom); final int offset = computeAnotherDirectionDefaultScrollOffset(); final int move = offset - mOffset; if (move == 0) return; if (getOrientation() == HORIZONTAL) { child.offsetTopAndBottom(move); } else { child.offsetLeftAndRight(move); } }
Example 12
Source Project: FadingActionBar File: ObservableWebViewWithHeader.java License: Apache License 2.0 | 5 votes |
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); View title = getChildAt(0); if (title != null) // undo horizontal scroll, so that title scrolls only vertically title.offsetLeftAndRight(l - title.getLeft()); if (mOnScrollChangedCallback != null) mOnScrollChangedCallback.onScroll(l, t); }
Example 13
Source Project: 920-text-editor-v2 File: TranslucentDrawerLayout.java License: Apache License 2.0 | 5 votes |
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); }
Example 14
Source Project: Nimingban File: PostLayout.java License: Apache License 2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); for (int i = 0, count = getChildCount(); i < count; i++) { View child = getChildAt(i); if (GONE == child.getVisibility()) { continue; } LayoutParams lp = (LayoutParams) child.getLayoutParams(); child.offsetLeftAndRight(lp.offsetX); child.offsetTopAndBottom(lp.offsetY); } }
Example 15
Source Project: AndroidProjects File: SwipeBackLayout.java License: MIT License | 5 votes |
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 (isLayoutRtl) { v.offsetLeftAndRight(-dx); } else { v.offsetLeftAndRight(dx); } if (dimViews) { dimChildView(v, isLayoutRtl ? mParallaxOffset - 1 : 1 - mParallaxOffset, mCoveredFadeColor); } } }
Example 16
Source Project: SimplifyReader File: PLAListView.java License: Apache License 2.0 | 4 votes |
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) { child.offsetLeftAndRight(offsetLeft); child.offsetTopAndBottom(offsetTop); }
Example 17
Source Project: SlideLayout File: SlideLayout.java License: GNU General Public License v2.0 | 4 votes |
private void offsetLeftAndRight(View v, int offset){ if(v == null) return; v.offsetLeftAndRight(offset); }
Example 18
Source Project: letv File: HListView.java License: Apache License 2.0 | 4 votes |
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; }
Example 19
Source Project: Rey-MusicPlayer File: VelocityViewPager.java License: Apache License 2.0 | 4 votes |
/** * This method will be invoked when the current page is scrolled, either as part * of a programmatically initiated smooth scroll or a user initiated touch scroll. * If you override this method you must call through to the superclass implementation * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled * returns. * * @param position Position index of the first page currently being displayed. * Page position+1 will be visible if positionOffset is nonzero. * @param offset Value from [0, 1) indicating the offset from the page at position. * @param offsetPixels Value in pixels indicating the offset from position. */ protected void onPageScrolled(int position, float offset, int offsetPixels) { // Offset any decor views if needed - keep them on-screen at all times. if (mDecorChildCount > 0) { final int scrollX = getScrollX(); int paddingLeft = getPaddingLeft(); int paddingRight = getPaddingRight(); final int width = getWidth(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.isDecor) continue; final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; int childLeft = 0; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } childLeft += scrollX; final int childOffset = childLeft - child.getLeft(); if (childOffset != 0) { child.offsetLeftAndRight(childOffset); } } } if (mOnPageChangeListener != null) { mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels); } if (mInternalPageChangeListener != null) { mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels); } transformPages(); mCalledSuper = true; }
Example 20
Source Project: Muzesto File: VelocityViewPager.java License: GNU General Public License v3.0 | 4 votes |
/** * This method will be invoked when the current page is scrolled, either as part * of a programmatically initiated smooth scroll or a user initiated touch scroll. * If you override this method you must call through to the superclass implementation * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled * returns. * * @param position Position index of the first page currently being displayed. * Page position+1 will be visible if positionOffset is nonzero. * @param offset Value from [0, 1) indicating the offset from the page at position. * @param offsetPixels Value in pixels indicating the offset from position. */ protected void onPageScrolled(int position, float offset, int offsetPixels) { // Offset any decor views if needed - keep them on-screen at all times. if (mDecorChildCount > 0) { final int scrollX = getScrollX(); int paddingLeft = getPaddingLeft(); int paddingRight = getPaddingRight(); final int width = getWidth(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.isDecor) continue; final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; int childLeft = 0; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } childLeft += scrollX; final int childOffset = childLeft - child.getLeft(); if (childOffset != 0) { child.offsetLeftAndRight(childOffset); } } } if (mOnPageChangeListener != null) { mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels); } if (mInternalPageChangeListener != null) { mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels); } transformPages(); mCalledSuper = true; }