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


Java RecyclerView.getHeight方法代碼示例

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


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

示例1: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@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();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
        final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child));
        final int left = right - mDivider.getIntrinsicWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
開發者ID:by-syk,項目名稱:NanoIconPack,代碼行數:27,代碼來源:DividerItemDecoration.java

示例2: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
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);
	}
}
 
開發者ID:lijunyandev,項目名稱:MeetMusic,代碼行數:18,代碼來源:DividerItemDecoration.java

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

示例4: onMoved

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void onMoved(RecyclerView recyclerView, ViewHolder viewHolder, int fromPos, ViewHolder target, int toPos, int x, int y) {
    LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof ViewDropHandler) {
        ((ViewDropHandler) layoutManager).prepareForDrop(viewHolder.itemView, target.itemView, x, y);
        return;
    }
    if (layoutManager.canScrollHorizontally()) {
        if (layoutManager.getDecoratedLeft(target.itemView) <= recyclerView.getPaddingLeft()) {
            recyclerView.scrollToPosition(toPos);
        }
        if (layoutManager.getDecoratedRight(target.itemView) >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
    if (layoutManager.canScrollVertically()) {
        if (layoutManager.getDecoratedTop(target.itemView) <= recyclerView.getPaddingTop()) {
            recyclerView.scrollToPosition(toPos);
        }
        if (layoutManager.getDecoratedBottom(target.itemView) >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:ItemTouchHelper.java

示例5: drawHorizontalDividers

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 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);

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

        int parentLeft = child.getRight() + params.rightMargin;
        int parentRight = parentLeft + mDivider.getIntrinsicWidth();

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

示例6: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
        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.getIntrinsicWidth();
            final int top;
            final int bottom;
            if (mOrientation == BOTH_LIST) {
                top = child.getTop() + parent.getPaddingTop() - params.topMargin;
                bottom = top + child.getMeasuredHeight() + params.bottomMargin;
            } else {
                top = parent.getPaddingTop();
                bottom = parent.getHeight() - parent.getPaddingBottom();
            }
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
//            Log.e(TAG, "drawHorizontal: " + left + " " + top + " " + right + " " + bottom);
        }
    }
 
開發者ID:YMlion,項目名稱:leisure-glance,代碼行數:23,代碼來源:DividerItemDecoration.java

示例7: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if(parent.getChildAdapterPosition(view) == 0) {
        if(orientation == SnappingRecyclerView.VERTICAL) {
            outRect.top = (parent.getHeight() / 2) - (view.getHeight() / 2);
        } else {
            outRect.left = (parent.getWidth() / 2) - (view.getWidth() / 2);
        }
    } else if (parent.getChildAdapterPosition(view) == parent.getAdapter().getItemCount() - 1) {
        if(orientation == SnappingRecyclerView.VERTICAL) {
            outRect.bottom = (parent.getHeight() / 2) - (view.getHeight() / 2);
        } else {
            outRect.right = (parent.getWidth() / 2) - (view.getWidth() / 2);
        }
    }
}
 
開發者ID:Dan-TD,項目名稱:SnappyRecyclerView,代碼行數:17,代碼來源:ExampleDateEndPaddingItemDecoration.java

示例8: onScrollStateChanged

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
  super.onScrollStateChanged(recyclerView, newState);
  currentScrollState = newState;
  RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
  int visibleItemCount = layoutManager.getChildCount();
  int totalItemCount = layoutManager.getItemCount();

  if (visibleItemCount != 0) {
    int bottomOffset = (totalItemCount - lastVisibleItemPosition - 1) * (recyclerView.getHeight()) / visibleItemCount;
    if (visibleItemCount > 0 && currentScrollState == RecyclerView.SCROLL_STATE_IDLE) {
      if (listener != null && listener.get() != null) {
        listener.get().onLoadMore(bottomOffset);
      }
    }
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:18,代碼來源:WXRecyclerViewOnScrollListener.java

示例9: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/** 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);
    }
}
 
開發者ID:CasterIO,項目名稱:RecyclerViewIntermediate,代碼行數:17,代碼來源:GridDividerDecoration.java

示例10: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:16,代碼來源:DividerItemDecoration.java

示例11: drawVDeraction

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製垂直方向的分割線
 * @param c
 * @param parent
 */
private void drawVDeraction(Canvas c, RecyclerView parent){
    int top=parent.getPaddingTop();
    int bottom=parent.getHeight()-parent.getPaddingBottom();
    int childCount=parent.getChildCount();
    for(int i=0;i<childCount;i++){
        View child=parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams=(RecyclerView.LayoutParams)child.getLayoutParams();
        int left=child.getRight()+layoutParams.rightMargin;
        int right=left+mDivider.getIntrinsicWidth();
        mDivider.setBounds(left,top,right,bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:AdvanceDecoration.java

示例12: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    int childCount = parent.getChildCount();

    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        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);
    }
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:16,代碼來源:DividerItemDecoration.java

示例13: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
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 + getDividerWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:androidDaniel,項目名稱:treasure,代碼行數:16,代碼來源:DividerItemDecoration.java

示例14: isItemsFitOnScreen

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public boolean isItemsFitOnScreen(RecyclerView rvCategories, int itemsSize) {
    calcItemHeight(rvCategories);
    int itemsHeight = itemHeight * (itemsSize);
    int containerHeight = rvCategories.getHeight();
    return containerHeight >= itemsHeight;
}
 
開發者ID:sinhaDroid,項目名稱:BlogBookApp,代碼行數:8,代碼來源:OrientationStateVertical.java

示例15: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    int top = parent.getPaddingTop();
    int bottom = parent.getHeight() - parent.getPaddingBottom();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        int left = (child.getRight() + ((LayoutParams) child.getLayoutParams()).rightMargin)
                + Math.round(ViewCompat.getTranslationX(child));
        this.mDivider.setBounds(left, top, left + this.mDivider.getIntrinsicHeight(), bottom);
        this.mDivider.draw(c);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:DividerItemDecoration.java


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