Java Code Examples for android.support.v7.widget.RecyclerView#getRight()
The following examples show how to use
android.support.v7.widget.RecyclerView#getRight() .
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: DividerItemDecoration.java From android-common-utils with Apache License 2.0 | 6 votes |
public void drawVertical(Canvas c, RecyclerView parent) { final int left = parent.getLeft(); final int right = parent.getRight(); final Drawable mDivider = this.getDividerManager().getDivider(); final int childCount = parent.getChildCount(); View child; RecyclerView.LayoutParams params; int top ; int bottom ; for (int i = 0; i < childCount; i++) { child = parent.getChildAt(i); params = (RecyclerView.LayoutParams) child.getLayoutParams(); top = child.getBottom() + params.bottomMargin; //分割线的top bottom = top + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 2
Source File: TableDecoration.java From ItemDecorationDemo with Apache License 2.0 | 5 votes |
/** * 当最后一行没有充满时需要填充缺陷的地方 */ private void drawLast(Canvas canvas, RecyclerView parent) { View lastView = parent.getChildAt(parent.getChildCount() - 1); int pos = parent.getChildAdapterPosition(lastView); if (isLastColumn((GridLayoutManager.LayoutParams) lastView.getLayoutParams(),pos)){ return; } int translationX = Math.round(lastView.getTranslationX()); int translationY = Math.round(lastView.getTranslationY()); int viewLeft = lastView.getLeft() + translationX; int viewRight = lastView.getRight() + translationX; int viewTop = lastView.getTop() + translationY; int viewBottom = lastView.getBottom() + translationY; parent.getDecoratedBoundsWithMargins(lastView, mBounds); canvas.save(); if (mManager.getOrientation() == LinearLayoutManager.VERTICAL) { int contentRight = parent.getRight() - parent.getPaddingRight() - Math.round(parent.getTranslationX()); //空白区域上边缘 mDivider.setBounds(mBounds.right, mBounds.top, contentRight, viewTop); mDivider.draw(canvas); //空白区域左边缘 mDivider.setBounds(viewRight, viewTop, viewRight + mSize, mBounds.bottom); mDivider.draw(canvas); }else { int contentBottom = parent.getBottom()-parent.getPaddingBottom()-Math.round(parent.getTranslationY()); //空白区域上边缘 mDivider.setBounds(mBounds.left,viewBottom,mBounds.right,viewBottom+mSize); mDivider.draw(canvas); //空白区域左边缘 mDivider.setBounds(mBounds.left,mBounds.bottom,viewLeft,contentBottom); mDivider.draw(canvas); } canvas.restore(); }
Example 3
Source File: SimpleDecoration.java From StickyDecoration with Apache License 2.0 | 5 votes |
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { super.onDraw(c, parent, state); final int left = parent.getLeft() + parent.getPaddingLeft(); final int right = parent.getRight() - parent.getPaddingRight(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View childView = parent.getChildAt(i); final int bottom = childView.getTop(); final int top = bottom - mHeight; c.drawRect(left, top, right, bottom, mPaint); } }
Example 4
Source File: WXItemDecoration.java From HightCopyWX with Apache License 2.0 | 5 votes |
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int count = parent.getChildCount(); int left = parent.getLeft() - parent.getPaddingLeft(); int right = parent.getRight() - parent.getPaddingRight(); for (int i = 0; i<count;i++){ int top = parent.getChildAt(i).getBottom() - parent.getChildAt(i).getPaddingBottom(); int bottom = parent.getChildAt(i).getBottom() + drawable.getIntrinsicHeight(); drawable.setBounds(left,top,right,bottom); drawable.draw(c); } }
Example 5
Source File: ColumnTest.java From ChipsLayoutManager with Apache License 2.0 | 5 votes |
private ViewHolderMatcher<RecyclerView.ViewHolder> rvPaddingMatcher() { return new RecyclerViewEspressoFactory.ViewHolderMatcher<RecyclerView.ViewHolder>() { @Override public boolean matches(RecyclerView parent, View itemView, RecyclerView.ViewHolder viewHolder) { int expectedPadding = parent.getPaddingRight(); int right = layoutManager.getDecoratedRight(itemView); int parentRight = parent.getRight(); int padding = parentRight - right; assertEquals("padding of RecyclerView item doesn't equal expected padding" ,expectedPadding, padding); return true; } }; }
Example 6
Source File: ViewUtils.java From MultiView with Apache License 2.0 | 5 votes |
public static View getFirstIntersectsChild(RecyclerView recyclerView) { int childCount = recyclerView.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { View child = recyclerView.getChildAt(i); Rect rect1=new Rect(recyclerView.getLeft(),recyclerView.getTop(), recyclerView.getRight(), recyclerView.getBottom()); Rect rect2=new Rect(child.getLeft(),child.getTop(), child.getRight(), child.getBottom()); if (Rect.intersects(rect1, rect2)) { return child; } } } return null; }
Example 7
Source File: DividerItemDecoration.java From easyrecycleradapters with Apache License 2.0 | 5 votes |
public void drawToTheRightOfEachChildren(Canvas c, RecyclerView parent) { if (parent.getChildCount() == 0) return; int top, left, right, bottom; int childCount = parent.getChildCount(); View currentChild; for (int i = 0; i < childCount; i++) { currentChild = parent.getChildAt(i); int offset = 2; if (currentChild.getRight() < parent.getRight() - parent.getPaddingRight() - offset) { //Avoid drawing over top padding top = currentChild.getTop(); if (top < parent.getPaddingTop()) { top = parent.getPaddingTop(); } bottom = currentChild.getBottom() + divider.getIntrinsicHeight(); //Avoid drawing over bottom padding int parentBottom = parent.getBottom() - parent.getPaddingBottom(); if (bottom > parentBottom) { bottom = parentBottom; } left = currentChild.getRight(); right = left + divider.getIntrinsicWidth(); divider.setBounds(left, top, right, bottom); divider.draw(c); } } }