Java Code Examples for android.support.v7.widget.RecyclerView#getPaddingBottom()
The following examples show how to use
android.support.v7.widget.RecyclerView#getPaddingBottom() .
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 File: VerticalDividerItemDecoration.java From ARecyclerView with MIT License | 6 votes |
@Override protected Rect getDividerBound(int position, RecyclerView parent, View child) { Rect bounds = new Rect(0, 0, 0, 0); int transitionX = (int) ViewCompat.getTranslationX(child); int transitionY = (int) ViewCompat.getTranslationY(child); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); bounds.top = parent.getPaddingTop() + mMarginProvider.dividerTopMargin(position, parent) + transitionY; bounds.bottom = parent.getHeight() - parent.getPaddingBottom() - mMarginProvider.dividerBottomMargin(position, parent) + transitionY; int dividerSize = getDividerSize(position, parent); if (mDividerType == DividerType.DRAWABLE) { bounds.left = child.getRight() + params.leftMargin + transitionX; bounds.right = bounds.left + dividerSize; } else { bounds.left = child.getRight() + params.leftMargin + dividerSize / 2 + transitionX; bounds.right = bounds.left; } return bounds; }
Example 2
Source File: RecyclerViewFragment.java From kernel_adiutor with Apache License 2.0 | 6 votes |
public void setOnScrollListener(RecyclerView recyclerView) { if (recyclerView != null) { int paddingBottom = recyclerView.getPaddingBottom() + getResources().getDimensionPixelSize(R.dimen.basecard_padding); if (applyOnBootLayout != null) { recyclerView.setPadding(0, applyOnBootLayout.getHeight(), 0, firstOpening ? paddingBottom : recyclerView.getPaddingBottom()); resetTranslations(); if (!Utils.isTV(getActivity())) recyclerView.addOnScrollListener(onScrollListener = new CustomScrollListener()); } else recyclerView.setPadding(0, 0, 0, firstOpening ? paddingBottom : recyclerView.getPaddingBottom()); recyclerView.setClipToPadding(false); } }
Example 3
Source File: DividerItemDecoration.java From MaterialRefreshLayoutDemo with Apache License 2.0 | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 4
Source File: DividerItemDecoration.java From double-direction-adapter-endless with MIT License | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child)); final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 5
Source File: DividerItemDecoration.java From Xrv with Apache License 2.0 | 6 votes |
/** * Adds dividers to a RecyclerView with a LinearLayoutManager or its * subclass oriented horizontally. * * @param canvas The {@link Canvas} onto which horizontal dividers will be * drawn * @param parent The RecyclerView onto which horizontal dividers are being * added */ private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) { int parentTop = parent.getPaddingTop(); int parentBottom = parent.getHeight() - parent.getPaddingBottom(); int childCount = parent.getChildCount(); for (int i = 0; i < childCount - 1; i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); int parentLeft = child.getRight() + params.rightMargin; int parentRight = parentLeft + mDivider.getIntrinsicWidth(); mDivider.setBounds(parentLeft, parentTop, parentRight, parentBottom); mDivider.draw(canvas); } }
Example 6
Source File: RecycleViewDivider.java From VideoPlayer with Apache License 2.0 | 6 votes |
private void drawVertical(Canvas canvas, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + mDividerHeight; if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } }
Example 7
Source File: DividerItemDecoration.java From AndroidMVVMSample with Apache License 2.0 | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDividerHeight;//mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 8
Source File: GridDividerDecoration.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** Draw dividers to the right of each child view */ public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + params.rightMargin + mInsets; final int right = left + mDivider.getIntrinsicWidth(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 9
Source File: DividerRVDecoration.java From SHSwipeRefreshLayout with MIT License | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 10
Source File: DividerItemDecoration.java From DexMovingImageView with Apache License 2.0 | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 11
Source File: DividedItemDecoration.java From JalanJalan with Do What The F*ck You Want To Public License | 5 votes |
private void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 12
Source File: DividerItemDecoration.java From ClockView with Apache License 2.0 | 5 votes |
/** * 绘制横向 item 分割线 * * @param canvas * @param parent */ private void drawHorizontal(Canvas canvas, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getWidth() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final float left = child.getRight() + layoutParams.rightMargin; final float right = left + mItemSize; canvas.drawRect(left, top, right, bottom, mPaint); } }
Example 13
Source File: DividerItemDecoration.java From ResearchStack with Apache License 2.0 | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child)); final int right = left + divider.getIntrinsicHeight(); divider.setBounds(left, top, right, bottom); divider.draw(c); } }
Example 14
Source File: DividerItemDecoration.java From AndroidAutoLayout with Apache License 2.0 | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 15
Source File: ShadowItemDecoration.java From PracticalRecyclerView with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") private void drawHorizontal(Canvas canvas, RecyclerView parent) { canvas.save(); final int top; final int bottom; if (parent.getClipToPadding()) { top = parent.getPaddingTop(); bottom = parent.getHeight() - parent.getPaddingBottom(); canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom); } else { top = 0; bottom = parent.getHeight(); } final int childCount = parent.getChildCount(); AbstractAdapter adapter = (AbstractAdapter) parent.getAdapter(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final int position = parent.getChildAdapterPosition(child); final int headerSize = adapter.getHeaderSize(); if (adapter.isData(position)) { if (mStrategy.strategy(position - headerSize)) { parent.getDecoratedBoundsWithMargins(child, mBounds); final int right = mBounds.right; final int left = mBounds.left; mShadowColor.setBounds(left, top, right, bottom); mShadowColor.draw(canvas); } } } canvas.restore(); }
Example 16
Source File: DividerItemDecoration.java From RxJoke with Apache License 2.0 | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 17
Source File: DividerItemDecoration.java From Leisure with GNU Lesser General Public License v3.0 | 5 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int left = child.getRight() + params.rightMargin; final int right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 18
Source File: VerticalDividerItemDecoration.java From AccountBook with GNU General Public License v3.0 | 4 votes |
@Override protected Rect getDividerBound(int position, RecyclerView parent, View child) { Rect bounds = new Rect(0, 0, 0, 0); int transitionX = (int) ViewCompat.getTranslationX(child); int transitionY = (int) ViewCompat.getTranslationY(child); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); bounds.top = parent.getPaddingTop() + mMarginProvider.dividerTopMargin(position, parent) + transitionY; bounds.bottom = parent.getHeight() - parent.getPaddingBottom() - mMarginProvider.dividerBottomMargin(position, parent) + transitionY; int dividerSize = getDividerSize(position, parent); boolean isReverseLayout = isReverseLayout(parent); if (mDividerType == DividerType.DRAWABLE) { // set left and right position of divider if (isReverseLayout) { bounds.right = child.getLeft() - params.leftMargin + transitionX; bounds.left = bounds.right - dividerSize; } else { bounds.left = child.getRight() + params.rightMargin + transitionX; bounds.right = bounds.left + dividerSize; } } else { // set center point of divider int halfSize = dividerSize / 2; if (isReverseLayout) { bounds.left = child.getLeft() - params.leftMargin - halfSize + transitionX; } else { bounds.left = child.getRight() + params.rightMargin + halfSize + transitionX; } bounds.right = bounds.left; } if (mPositionInsideItem) { if (isReverseLayout) { bounds.left += dividerSize; bounds.right += dividerSize; } else { bounds.left -= dividerSize; bounds.right -= dividerSize; } } return bounds; }
Example 19
Source File: DividerItemDecoration.java From KUtils with Apache License 2.0 | 4 votes |
/** * 绘制横向 item 分割线 这里的parent其实是显示在屏幕显示的这部分 */ private void drawHorizontal(Canvas canvas, RecyclerView parent) { /** 当orientation为 Horizontal 时,Item的分割线为多条竖直的条形 所以,分割线的Top和Bottom就比较容易确定 top = parent.top = parent.paddingTop bottom = parent.getHeight() - parent.getPaddingBottom() 分割线的 left 和 right 则需要计算出有多少个Item 根据Item的位置获取到child的位置坐标 所以分割线的left = child的右边的坐标 + child的外边距的距离 left = child.right + parms.rightMargin 然后根据左边 + 分割线的宽度 得到右边的坐标 right = left + mDivider.getIntrinsicHeight() 为了统一分割线的间隔,故共同使用Height的数值作为间隔的距离 */ final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + mDividerHeight; /**横向列表*/ if (i == 0) { if (isMarginTopShow) { /**第一个view,可以在顶部加一个margin值*/ int leftF = child.getLeft() - layoutParams.leftMargin - mDividerHeight; int rightF = child.getLeft() - layoutParams.leftMargin; if (mDivider != null) { mDivider.setBounds(leftF, top, rightF, bottom); mDivider.draw(canvas); if (isMiddleShow) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } } if (mPaint != null) { canvas.drawRect(leftF, top, rightF, bottom, mPaint); if (isMiddleShow) { canvas.drawRect(left, top, right, bottom, mPaint); } } } else { if (isMiddleShow) { if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } } } else { if (isMiddleShow || i >= childSize - 1) { /**画竖线,就是往右偏移一个分割线的宽度*/ if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } } } }
Example 20
Source File: SearchDivider.java From MeiZiNews with MIT License | 4 votes |
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (divider == null) { super.onDraw(c, parent, state); return; } int left = 0; int right = 0; int top = 0; int bottom = 0; final int orientation = getOrientation(parent); final int childCount = parent.getChildCount(); final boolean vertical = orientation == LinearLayoutManager.VERTICAL; final int size; if (vertical) { size = dividerHeight; left = parent.getPaddingLeft(); right = parent.getWidth() - parent.getPaddingRight(); } else { size = dividerWidth; top = parent.getPaddingTop(); bottom = parent.getHeight() - parent.getPaddingBottom(); } for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int position = params.getViewLayoutPosition(); if (position == 0) { continue; } if (vertical) { top = child.getTop() - params.topMargin - size; bottom = top + size; } else { left = child.getLeft() - params.leftMargin - size; right = left + size; } divider.setBounds(left, top, right, bottom); divider.draw(c); } }