本文整理匯總了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
}