当前位置: 首页>>代码示例>>Java>>正文


Java RecyclerView.getDecoratedBoundsWithMargins方法代码示例

本文整理汇总了Java中android.support.v7.widget.RecyclerView.getDecoratedBoundsWithMargins方法的典型用法代码示例。如果您正苦于以下问题:Java RecyclerView.getDecoratedBoundsWithMargins方法的具体用法?Java RecyclerView.getDecoratedBoundsWithMargins怎么用?Java RecyclerView.getDecoratedBoundsWithMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.getDecoratedBoundsWithMargins方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent, View child) {
  canvas.save();
  final int left;
  final int right;
  if (parent.getClipToPadding()) {
    left = parent.getPaddingLeft();
    right = parent.getWidth() - parent.getPaddingRight();
    canvas.clipRect(left, parent.getPaddingTop(), right,
        parent.getHeight() - parent.getPaddingBottom());
  } else {
    left = 0;
    right = parent.getWidth();
  }

  parent.getDecoratedBoundsWithMargins(child, mBounds);
  final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
  final int top = bottom - mDivider.getIntrinsicHeight();
  mDivider.setBounds(left, top, right, bottom);
  mDivider.draw(canvas);
  canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SimpleDividerDecoration.java

示例2: draw

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi") private void draw(Canvas canvas, RecyclerView parent, View child) {
  canvas.save();
  final int left;
  final int right;
  if (parent.getClipToPadding()) {
    left = parent.getPaddingLeft();
    right = parent.getWidth() - parent.getPaddingRight();
    canvas.clipRect(left, parent.getPaddingTop(), right,
        parent.getHeight() - parent.getPaddingBottom());
  } else {
    left = 0;
    right = parent.getWidth();
  }

  parent.getDecoratedBoundsWithMargins(child, mBounds);
  final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
  final int top = bottom - 16;

  canvas.drawRect(left, top, right, bottom, myPaint);
  canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ArticleItemDecorator.java

示例3: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent, View child) {
  canvas.save();
  final int left;
  final int right;
  if (parent.getClipToPadding()) {
    left = parent.getPaddingLeft();
    right = parent.getWidth() - parent.getPaddingRight();
    canvas.clipRect(left, parent.getPaddingTop(), right,
        parent.getHeight() - parent.getPaddingBottom());
  } else {
    left = 0;
    right = parent.getWidth();
  }

  parent.getDecoratedBoundsWithMargins(child, mBounds);
  final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
  final int top = bottom - mDivider.getIntrinsicHeight() * 4;
  mDivider.setBounds(left, top, right, bottom);
  mDivider.draw(canvas);
  canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:ThickItemDecorator.java

示例4: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
protected void drawVertical(Canvas canvas, RecyclerView parent) {
    canvas.save();
    final int left;
    final int right;
    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
        final int top = bottom - mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:RecycleViewDivider.java

示例5: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent) {
    canvas.save();
    final int left;
    final int right;
    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
        final int top = bottom - mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:27,代码来源:CustomDividerItemDecoration.java

示例6: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
    private void drawVertical(Canvas canvas, RecyclerView parent) {
        canvas.save();
        final int left;
        final int right;
        if (parent.getClipToPadding()) {
            left = parent.getPaddingLeft();
            right = parent.getWidth() - parent.getPaddingRight();
            canvas.clipRect(left, parent.getPaddingTop(), right,
                    parent.getHeight() - parent.getPaddingBottom());
        } else {
            left = 0;
            right = parent.getWidth();
        }

        final int childCount = parent.getChildCount();
//        for (int i = 0; i < childCount; i++) {
        // Remove the last divider
        // @By_syk
        for (int i = 0; i < childCount - 1; i++) {
            final View child = parent.getChildAt(i);
            parent.getDecoratedBoundsWithMargins(child, mBounds);
            final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
            final int top = bottom - mDivider.getIntrinsicHeight();
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        canvas.restore();
    }
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:30,代码来源:DividerItemDecoration.java

示例7: drawVertical

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent) {
    canvas.save();
    int left;
    int right;
    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }
    if(mDividerPadding > 0){//设置了padding,调整left和right的值
        left = left + mDividerPadding;
        right = right - mDividerPadding;
    }

    mDivider.setColor(mDividerColor);//自定义color,没设置就用默认值
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
        int top = bottom - mDivider.getIntrinsicHeight();
        if(mVerticalDividerHeight > 0){//如果设置了高度,调整top的值
            top = bottom - mVerticalDividerHeight;
        }

        mDivider.setBounds(left, top, right, bottom);
        //mDivider.setCornerRadius();//设置矩形圆角
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:yangjiantao,项目名称:AndroidUiKit,代码行数:37,代码来源:IDividerItemDecoration.java

示例8: onDraw

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    if (parent.getLayoutManager() == null || divider == null) {
        return;
    }

    canvas.save();
    final int left;
    final int right;

    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        final int bottom = mBounds.bottom + Math.round(child.getTranslationY());
        final int top = bottom - divider.getIntrinsicHeight();
        divider.setBounds(left + leftMargin, top, right - rightMargin, bottom);
        divider.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:32,代码来源:MarginItemDecorator.java

示例9: onDraw

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    canvas.save();
    final int left;
    final int right;
    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        if (!hasDivider(parent, child))
            continue;
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
        final int top = bottom - mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.setAlpha((int) (child.getAlpha() * 255));
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:29,代码来源:AdvancedDividerItemDecoration.java

示例10: onDraw

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    if (parent.getLayoutManager() == null) {
        return;
    }
    canvas.save();
    final int left;
    final int right;
    if (parent.getClipToPadding()) {
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
        canvas.clipRect(left, parent.getPaddingTop(), right,
                parent.getHeight() - parent.getPaddingBottom());
    } else {
        left = 0;
        right = parent.getWidth();
    }

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getDecoratedBoundsWithMargins(child, mBounds);
        Object object = child.getTag(R.id.item_divider);
        if (object != null && object instanceof Drawable) {
            Drawable drawable = (Drawable) object;
            final int top = mBounds.top + Math.round(child.getTranslationX());
            final int bottom = mBounds.top + drawable.getIntrinsicHeight();
            drawable.setBounds(left, top, right, bottom);
            drawable.draw(canvas);
        }
    }
    canvas.restore();
}
 
开发者ID:msdx,项目名称:group-recycler-adapter,代码行数:34,代码来源:GroupItemDecoration.java

示例11: draw

import android.support.v7.widget.RecyclerView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void draw(Canvas c, RecyclerView parent)
{
    int childCount = parent.getChildCount();

    if(parent.getClipToPadding())
    {
        c.clipRect(parent.getPaddingLeft(), parent.getPaddingTop(),
                parent.getWidth() - parent.getPaddingRight(),
                parent.getHeight() - parent.getPaddingBottom());
    }

    int top = parent.getPaddingTop();
    int preHeaderId;
    int headerId = NO_POSITION;
    int x = parent.getPaddingLeft();
    for(int i = 0; i < childCount; i++)
    {
        View itemView = parent.getChildAt(i);
        int position = parent.getChildAdapterPosition(itemView);

        //只有各组第一个 并且 headerId!=-1 才绘制头部view
        preHeaderId = headerId;
        headerId = getHeaderId(position);
        if(headerId <= NO_POSITION || headerId == preHeaderId)
        {
            continue;
        }

        View header = getHeaderView(parent, position);

        int heightWithPadding = header.getHeight() + top;
        int y = Math.max(heightWithPadding, itemView.getTop());
        if(isStick)
        {
            int nextPosition = getNextHeadPosition(i, headerId, childCount, parent);
            if(nextPosition != NO_POSITION)
            {
                View nextView = parent.getChildAt(nextPosition);
                //获得真实位置后再进行判断
                parent.getDecoratedBoundsWithMargins(nextView, rect);
                //判断下一个头部view是否到了与上一个头部view接触的临界值
                //如果满足条件则把上一个头部view推上去
                if(rect.top <= heightWithPadding)
                {
                    //这里使用nextView.getTop 直接减掉 header.getHeight(),如果减去heightWithPadding,
                    //会出现移动时的间距
                    y = nextView.getTop() - header.getHeight();
                }
            }
        }

        //这个时候,y是header底部位置,需要减去它的高度,修正定位
        y -= header.getHeight();
        c.translate(x, y);
        header.draw(c);
        //修正回来
        c.translate(-x, -y);
    }
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:61,代码来源:StickyHeaderItemDecoration.java


注:本文中的android.support.v7.widget.RecyclerView.getDecoratedBoundsWithMargins方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。