public RecyclerViewLayoutManagerAssert hasPaddingLeft(int padding) { isNotNull(); int actualPadding = actual.getPaddingLeft(); assertThat(actualPadding) // .overridingErrorMessage("Expected padding left <%s> but was <%s>.", padding, actualPadding) // .isEqualTo(padding); return this; }
- layoutManager.getPaddingRight() - layoutManager.getDecoratedRight(firstView) : layoutManager.getDecoratedLeft(firstView) - layoutManager.getPaddingLeft(); } else { mCurrentOffset =
public RecyclerViewLayoutManagerAssert hasPaddingLeft(int padding) { isNotNull(); int actualPadding = actual.getPaddingLeft(); assertThat(actualPadding) // .overridingErrorMessage("Expected padding left <%s> but was <%s>.", padding, actualPadding) // .isEqualTo(padding); return this; }
/** * Calculates the horizontal scroll amount necessary to make the given view fully visible * inside the RecyclerView. * * @param view The view which we want to make fully visible * @param snapPreference The edge which the view should snap to when entering the visible * area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or * {@link #SNAP_TO_END} * @return The vertical scroll amount necessary to make the view visible with the given * snap preference. */ public int calculateDxToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollHorizontally()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin; final int right = layoutManager.getDecoratedRight(view) + params.rightMargin; final int start = layoutManager.getPaddingLeft(); final int end = layoutManager.getWidth() - layoutManager.getPaddingRight(); return calculateDtToFit(left, right, start, end, snapPreference); }
/** * Calculates the horizontal scroll amount necessary to make the given view in center of the RecycleView * * @param view The view which we want to make in center of the RecycleView * @return The horizontal scroll amount necessary to make the view in center of the RecycleView */ public int calculateDxToMakeCentral(View view) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollHorizontally()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin; final int right = layoutManager.getDecoratedRight(view) + params.rightMargin; final int start = layoutManager.getPaddingLeft(); final int end = layoutManager.getWidth() - layoutManager.getPaddingRight(); final int childCenter = left + (int) ((right - left) / 2.0f); final int containerCenter = (int) ((end - start) / 2.f); return containerCenter - childCenter; }
private int adjustDxForRight(int dx) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollHorizontally()) { return 0; } final View firstChild = layoutManager.getChildAt(0); final int position = layoutManager.getPosition(firstChild); if (position == 0) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) firstChild.getLayoutParams(); final int maxDx = -(layoutManager.getDecoratedLeft(firstChild) - params.leftMargin) + layoutManager.getPaddingLeft(); if (dx > maxDx) { return maxDx; } } return dx; }
@Override public int getStartAfterPadding() { return mLayoutManager.getPaddingLeft(); }
@Override public int getStartAfterPadding() { return mLayoutManager.getPaddingLeft(); }
@Override public int getStartAfterPadding() { return mLayoutManager.getPaddingLeft(); }
@Override public int getTotalSpace() { return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft() - mLayoutManager.getPaddingRight(); }
@Override public int getTotalSpace() { return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft() - mLayoutManager.getPaddingRight(); }
@Override public int getTotalSpaceInOther() { return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft() - mLayoutManager.getPaddingRight(); }
@Override public int getTotalSpace() { return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft() - mLayoutManager.getPaddingRight(); }
@Override public int getTotalSpaceInOther() { return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft() - mLayoutManager.getPaddingRight(); }