本文整理匯總了Java中android.support.v7.widget.RecyclerView.getPaddingBottom方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getPaddingBottom方法的具體用法?Java RecyclerView.getPaddingBottom怎麽用?Java RecyclerView.getPaddingBottom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getPaddingBottom方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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 + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例2: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawHorizontal(Canvas canvas, 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-1; 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();
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
示例3: 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);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
int parentLeft = child.getRight() + params.rightMargin;
int parentRight = parentLeft + mDivider.getIntrinsicWidth();
mDivider.setBounds(parentLeft, parentTop, parentRight, parentBottom);
mDivider.draw(canvas);
}
}
示例4: 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);
}
}
示例5: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 繪製間隔
*/
private 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 + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例6: 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);
}
}
}
示例7: 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();
}
示例8: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawVertical(Canvas canvas, RecyclerView parent) {
if (mDividerDrawable == null) {
return;
}
drawVerticalDividerBeforeFirstView(canvas, parent);
int top = parent.getPaddingTop();
int bottom = parent.getHeight() - 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;
if (i == childSize - 1) {
right = left + mAfterFooterDividerWidth;
} else {
right = left + mItemsDividerWidth;
}
mDividerDrawable.setBounds(left, top, right, bottom);
mDividerDrawable.draw(canvas);
}
}
示例9: 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);
}
}
示例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();
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);
}
}
示例11: 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);
}
}
示例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();
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);
}
}
示例13: onDraw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
int top;
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();
}
//畫線
int parentWidth = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight();
verticalLine.setBounds(parentWidth / 2 - 1, top, parentWidth / 2 + 1, bottom);
verticalLine.draw(canvas);
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; ++i) {
final View child = parent.getChildAt(i);
parent.getLayoutManager().getDecoratedBoundsWithMargins(child, this.mBounds);
// Log.e("mBounds", child.getLeft() + " " + child.getTop() + " " + child.getRight() + " " +
// child.getBottom() + " " + child.getWidth() + " " + child.getHeight() + " " + mBounds.toString());
// 計算水平線擺放的位置、擺放
if (parent.getChildAdapterPosition(child) % 2 == 0) {
rect.left = child.getRight();
rect.top = child.getTop() + child.getHeight() / 3;
rect.right = mBounds.right;
rect.bottom = rect.top + 1;
} else if (parent.getChildAdapterPosition(child) % 2 == 1) {
rect.left = parentWidth / 2;
rect.top = child.getTop() + child.getHeight() / 3;
rect.right = child.getLeft();
rect.bottom = rect.top + 1;
}
horizontalLine.setBounds(rect);
horizontalLine.draw(canvas);
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
// 計算圖片擺放位置、擺放
rect.left = parentWidth / 2 - w / 2;
rect.top = child.getTop() + child.getHeight() / 3 - h / 2;
rect.right = rect.left + w;
rect.bottom = rect.top + h;
drawable.setBounds(rect);
drawable.draw(canvas);
}
canvas.restore();
}
示例14: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 繪製橫向 item 分割線 這裏的parent其實是顯示在屏幕顯示的這部分
*/
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
/**
當orientation為 Horizontal 時,Item的分割線為多條豎直的條形
所以,分割線的Top和Bottom就比較容易確定
top = parent.top = parent.paddingTop
bottom = parent.getHeight() - parent.getPaddingBottom()
分割線的 left 和 right 則需要計算出有多少個Item
根據Item的位置獲取到child的位置坐標
所以分割線的left = child的右邊的坐標 + child的外邊距的距離
left = child.right + parms.rightMargin
然後根據左邊 + 分割線的寬度 得到右邊的坐標
right = left + mDivider.getIntrinsicHeight()
為了統一分割線的間隔,故共同使用Height的數值作為間隔的距離
*/
final int top = parent.getPaddingTop();
final int bottom = parent.getHeight() - 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 (i == 0) {
if (isMarginTopShow) {
/**第一個view,可以在頂部加一個margin值*/
int leftF = child.getLeft() - layoutParams.leftMargin - mDividerHeight;
int rightF = child.getLeft() - layoutParams.leftMargin;
if (mDivider != null) {
mDivider.setBounds(leftF, top, rightF, bottom);
mDivider.draw(canvas);
if (isMiddleShow) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
}
if (mPaint != null) {
canvas.drawRect(leftF, top, rightF, bottom, mPaint);
if (isMiddleShow) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
} else {
if (isMiddleShow) {
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
} else {
if (isMiddleShow || i >= childSize - 1) {
/**畫豎線,就是往右偏移一個分割線的寬度*/
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
}
}