當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.getWidth方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getWidth方法的具體用法?Java RecyclerView.getWidth怎麽用?Java RecyclerView.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDrawOver

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();

    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);

        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        int top = child.getBottom() + params.bottomMargin;
        int bottom = top + mDivider.getIntrinsicHeight();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:19,代碼來源:SimpleDividerItemDecoration.java

示例2: drawVerticalDividers

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * Adds dividers to a RecyclerView with a LinearLayoutManager or its
 * subclass oriented vertically.
 *
 * @param canvas The {@link Canvas} onto which vertical dividers will be
 *               drawn
 * @param parent The RecyclerView onto which vertical dividers are being
 *               added
 */
private void drawVerticalDividers(Canvas canvas, RecyclerView parent) {
    int parentLeft = parent.getPaddingLeft();
    int parentRight = parent.getWidth() - parent.getPaddingRight();

    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 parentTop = child.getBottom() + params.bottomMargin;
        int parentBottom = parentTop + mDivider.getIntrinsicHeight();

        mDivider.setBounds(parentLeft, parentTop, parentRight, parentBottom);
        mDivider.draw(canvas);
    }
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:27,代碼來源:XRecyclerView.java

示例3: onDrawOver

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if(mDivider != null) {
        int left = parent.getPaddingLeft();
        int right = parent.getWidth() - parent.getPaddingRight();

        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = parent.getChildAt(i);

            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

            int top = child.getBottom() + params.bottomMargin;
            int bottom = top + mDivider.getIntrinsicHeight();

            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
}
 
開發者ID:lecrec,項目名稱:lecrec-android,代碼行數:21,代碼來源:RecyclerDividerDecoration.java

示例4: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        // 有腳部時,最後一條不畫
        if (hasFooter &&
                parent.getChildLayoutPosition(child) == parent.getLayoutManager().getItemCount() - 1) {
            continue;
        }
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:DividerItemDecoration.java

示例5: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
  final int left = parent.getPaddingLeft();
  final int right = parent.getWidth() - parent.getPaddingRight();
  final int recyclerViewTop = parent.getPaddingTop();
  final int recyclerViewBottom = 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 top = Math.max(recyclerViewTop, child.getBottom() + params.bottomMargin);
    final int bottom = Math.min(recyclerViewBottom, top + mDivider.getIntrinsicHeight());
    mDivider.setBounds(left, top, right, bottom);
    mDivider.draw(c);
  }
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:17,代碼來源:DividerDecoration.java

示例6: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent)
{
	final int left = parent.getPaddingLeft() + DIVIDER_PADING_LEFT;
	final int right = parent.getWidth() - parent.getPaddingRight();

	final int childCount = parent.getChildCount();

	for (int i = 0; i < childCount; i++)
	{
		final View child = parent.getChildAt(i);
		RecyclerView v = new RecyclerView(
				parent.getContext());
		final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
				.getLayoutParams();
		final int top = child.getBottom() + params.bottomMargin;
		final int bottom = top + mDivider.getIntrinsicHeight();
		mDivider.setBounds(left, top, right, bottom);
		mDivider.draw(c);
	}
}
 
開發者ID:lijunyandev,項目名稱:MeetMusic,代碼行數:21,代碼來源:DividerItemDecoration.java

示例7: 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

示例8: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製間隔
 */
private void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();
    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 top = child.getBottom() + params.bottomMargin +
                Math.round(ViewCompat.getTranslationY(child));
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:MDLinearRvDividerDecoration.java

示例9: getDividerBound

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@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.left = parent.getPaddingLeft() +
            mMarginProvider.dividerLeftMargin(position, parent) + transitionX;
    bounds.right = parent.getWidth() - parent.getPaddingRight() -
            mMarginProvider.dividerRightMargin(position, parent) + transitionX;

    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.top = child.getBottom() + params.topMargin + transitionY;
        bounds.bottom = bounds.top + dividerSize;
    } else {
        bounds.top = child.getBottom() + params.topMargin + dividerSize / 2 + transitionY;
        bounds.bottom = bounds.top;
    }

    return bounds;
}
 
開發者ID:Jusenr,項目名稱:AppFirCloud,代碼行數:23,代碼來源:HorizontalDividerItemDecoration.java

示例10: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int count = parent.getChildCount() - (mDrawLast ? 0 : 1);
    for (int i = 0; i < count; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDividerWidth;
        mDivider.setBounds(left + mMarginStart, top, right - mMarginEnd, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:16,代碼來源:DividerItemDecoration.java

示例11: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    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 top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:gothalo,項目名稱:Android-2017,代碼行數:16,代碼來源:DividerItemDecoration.java

示例12: onDrawOver

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
  super.onDrawOver(c, parent, state);
  int width = parent.getWidth();
  int height = parent.getHeight();
  for (int i = 0,count=parent.getChildCount(); i < count; i++) {
    updateItem(parent.getChildAt(i),width,height);
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:10,代碼來源:TransformItemDecoration.java

示例13: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount-1; i++) {//最後一個item不畫divider
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:16,代碼來源:DividerItemDecoration.java

示例14: 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

示例15: 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,項目名稱:GxIconAndroid,代碼行數:30,代碼來源:DividerItemDecoration.java


注:本文中的android.support.v7.widget.RecyclerView.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。