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


Java RecyclerView.getMeasuredHeight方法代碼示例

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


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

示例1: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製橫向水平分割線
 */
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    int top = parent.getPaddingTop();
    int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getRight() + layoutParams.rightMargin;
        int right = left + mDividerWidth;

        if (mDividerDrawable != null) {
            //如果是圖片分割線,繪製圖片
            mDividerDrawable.setBounds(left, top, right, bottom);
            canvas.drawPaint(mPaint);
            mDividerDrawable.draw(canvas);
        } else {
            //繪製矩形
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:25,代碼來源:UIDivider.java

示例2: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawVertical(Canvas canvas, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:RecycleViewDivider.java

示例3: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製橫向 item 分割線
 *
 * @param canvas
 * @param parent
 */
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mItemSize;
        canvas.drawRect(left, top, right, bottom, mPaint);
    }
}
 
開發者ID:Yuanhongliang,項目名稱:HLOLI,代碼行數:19,代碼來源:DividerDecoration.java

示例4: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製橫向 item 分割線
 * 
 * @param canvas
 * @param parent
 */
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
	final int top = parent.getPaddingTop();
	final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
	final int childSize = parent.getChildCount();
	for (int i = 0; i < childSize; i++) {
		final View child = parent.getChildAt(i);
		RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
		final int left = child.getRight() + layoutParams.rightMargin;
		final int right = left + mItemSize;
		canvas.drawRect(left, top, right, bottom, mPaint);
	}
}
 
開發者ID:pao11,項目名稱:BaseAdapterRel,代碼行數:19,代碼來源:ListItemDecoration.java

示例5: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawVertical(Canvas c, RecyclerView parent){
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for(int i = 0; i < childCount; i++){
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams  =(RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mDividerWidth;
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:SirLYC,項目名稱:Android-Gank-Share,代碼行數:14,代碼來源:ItemDecoration.java

示例6: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 繪製縱向 item 分割線。上、下、左都是可計算的,右側需要獲取給定的寬度值
 * @param canvas
 * @param parent
 */
private void drawVertical(Canvas canvas, RecyclerView parent) {
    //上邊:到父容器的top內間距位置值
    final int top = parent.getPaddingTop();
    //下邊:到父容器的bottom內間距位置值
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    //循環繪製每條分割線
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        //左邊:具體的某條分割線的左邊以child的(right+rightMargin)位置值
        final int left = child.getRight() + layoutParams.rightMargin;
        //右邊:根據類型判斷
        int right;
        switch (drawType){
            case USEPAINT://構造方法聲明使用畫筆繪製
                //右邊:left加上指定的寬度
                right = left + mPaintDividerLength;
                if (mPaint != null) {
                    canvas.drawRect(left, top, right, bottom, mPaint);
                }
                break;
            case USEDRAWABLE://構造方法聲明使用drawable
                if (mDrawableDivider != null) {
                    //右邊:left加上指定的寬度
                    right = left + mDrawableDivider.getIntrinsicWidth();
                    mDrawableDivider.setBounds(left, top, right, bottom);
                    mDrawableDivider.draw(canvas);
                }
                break;
        }
    }

}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:40,代碼來源:RecycleViewDivider.java


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