本文整理匯總了Java中android.support.v7.widget.RecyclerView.getPaddingRight方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getPaddingRight方法的具體用法?Java RecyclerView.getPaddingRight怎麽用?Java RecyclerView.getPaddingRight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getPaddingRight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDraw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(final Canvas c, final RecyclerView parent, final RecyclerView.State state) {
// Apply the insets via the left and right position
final int leftPosition = parent.getPaddingLeft() + leftInsetPx;
final int rightPosition = parent.getWidth() - parent.getPaddingRight() - rightInsetPx;
// Show the decoration below every RecyclerView item
for (int i = 0; i < parent.getChildCount(); i++) {
// Need to draw relative to the RecyclerView child
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
// Position the divider below the child item and set the thickness
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + dividerDrawable.getIntrinsicHeight();
// Apply the position variables then draw the divider
dividerDrawable.setBounds(leftPosition, top, rightPosition, bottom);
dividerDrawable.draw(c);
}
}
示例2: 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++) {
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();
}
示例3: onDraw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
if (horizontalPadding != 0) {
left = horizontalPadding;
right = parent.getWidth() - horizontalPadding;
}
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 top = child.getBottom() + params.bottomMargin;
int bottom = top + divider.getIntrinsicHeight();
divider.setBounds(left, top, right, bottom);
divider.draw(c);
}
}
示例4: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
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 top = child.getBottom() + layoutParams.bottomMargin;
final int bottom = top + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
示例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 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);
}
}
示例6: 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);
}
}
}
示例7: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft()+40;
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);
android.support.v7.widget.RecyclerView v = new android.support.v7.widget.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);
}
}
示例8: 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);
}
}
示例9: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
if (mDividerDrawable == null) {
return;
}
drawHorizontalDividerBeforeFirstView(canvas, parent);
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
int top = child.getBottom() + layoutParams.bottomMargin;
int bottom;
if (i == childSize - 1) {
bottom = top + mAfterFooterDividerWidth;
} else {
bottom = top + mItemsDividerWidth;
}
mDividerDrawable.setBounds(left, top, right, bottom);
mDividerDrawable.draw(canvas);
}
}
示例10: 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);
android.support.v7.widget.RecyclerView v = new android.support.v7.widget.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);
}
}
示例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);
android.support.v7.widget.RecyclerView v = new android.support.v7.widget.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);
}
}
示例12: getClipRectForHeader
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Gets a clipping rect for the header based on the margins of the header and the padding of the
* recycler.
* FIXME: Currently right margin in VERTICAL orientation and bottom margin in HORIZONTAL
* orientation are clipped so they look accurate, but the headers are not being drawn at the
* correctly smaller width and height respectively.
*
* @param recyclerView for which to provide a header
* @param header for clipping
* @return a {@link Rect} for clipping a provided header to the padding of a recycler view
*/
private Rect getClipRectForHeader(RecyclerView recyclerView, View header) {
Rect headerMargins = mDimensionCalculator.getMargins(header);
if (mOrientationProvider.getOrientation(recyclerView) == LinearLayout.VERTICAL) {
return new Rect(
recyclerView.getPaddingLeft(),
recyclerView.getPaddingTop(),
recyclerView.getWidth() - recyclerView.getPaddingRight() - headerMargins.right,
recyclerView.getHeight() - recyclerView.getPaddingBottom());
} else {
return new Rect(
recyclerView.getPaddingLeft(),
recyclerView.getPaddingTop(),
recyclerView.getWidth() - recyclerView.getPaddingRight(),
recyclerView.getHeight() - recyclerView.getPaddingBottom() - headerMargins.bottom);
}
}
示例13: drawHorizontalLine
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontalLine(Canvas c, RecyclerView parent, RecyclerView.State state){
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++){
final View child = parent.getChildAt(i);
//獲得child的布局信息
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);
//Log.d("wnw", left + " " + top + " "+right+" "+bottom+" "+i);
}
}
示例14: 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);
}
}
示例15: 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();
}