Java Code Examples for android.support.v7.widget.RecyclerView#getBottom()
The following examples show how to use
android.support.v7.widget.RecyclerView#getBottom() .
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 drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getTop(); final int bottom = parent.getBottom(); final Drawable mDivider = this.getDividerManager().getDivider(); final int childCount = parent.getChildCount(); View child ; RecyclerView.LayoutParams params ; int left, right; for (int i = 0; i < childCount; i++) { child = parent.getChildAt(i); params = (RecyclerView.LayoutParams) child.getLayoutParams(); //分割线的left,right left = child.getRight() + params.rightMargin; right = left + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } }
Example 2
Source File: DividerItemDecoration.java From easyrecycleradapters with Apache License 2.0 | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { int childCount = parent.getChildCount(); if (childCount == 0) return; int left, top , right, bottom; View currentChild; for (int i = 0; i < childCount; i++) { currentChild = parent.getChildAt(i); int currentChildBottom = currentChild.getBottom(); if (currentChildBottom > parent.getPaddingTop() && currentChildBottom < parent.getBottom() - parent.getPaddingBottom()) { left = currentChild.getLeft(); right = currentChild.getRight(); top = currentChildBottom; bottom = top + divider.getIntrinsicHeight(); divider.setBounds(left, top, right, bottom); divider.draw(c); } } }
Example 3
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 4
Source File: RowTest.java From ChipsLayoutManager with Apache License 2.0 | 5 votes |
private ViewHolderMatcher<RecyclerView.ViewHolder> rvPaddingMatcher() { return new ViewHolderMatcher<RecyclerView.ViewHolder>() { @Override public boolean matches(RecyclerView parent, View itemView, RecyclerView.ViewHolder viewHolder) { int expectedPadding = parent.getPaddingBottom(); int bottom = layoutManager.getDecoratedBottom(itemView); int parentBottom = parent.getBottom(); int padding = parentBottom - bottom; assertEquals("padding of RecyclerView item doesn't equal expected padding" ,expectedPadding, padding); return true; } }; }
Example 5
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 6
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); } } }