本文整理匯總了Java中android.support.v7.widget.RecyclerView.getPaddingTop方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getPaddingTop方法的具體用法?Java RecyclerView.getPaddingTop怎麽用?Java RecyclerView.getPaddingTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getPaddingTop方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例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);
}
}
示例3: drawVerticalDividerBeforeFirstView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void drawVerticalDividerBeforeFirstView(Canvas canvas, RecyclerView parent) {
View child = parent.getChildAt(0);
if (child == null) {
return;
}
int top = parent.getPaddingTop();
int bottom = parent.getHeight() - parent.getPaddingBottom();
int right;
int left;
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
right = child.getLeft() + layoutParams.leftMargin;
int position = parent.getChildAdapterPosition(child);
if (position == 0) {
left = right - mBeforeHeaderDividerWidth;
} else {
left = right - mItemsDividerWidth;
}
mDividerDrawable.setBounds(left, top, right, bottom);
mDividerDrawable.draw(canvas);
}
示例4: 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);
}
}
}
示例5: 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 float right = left + mItemSize;
if (mDivider != null) {
mDivider.setBounds(left, top, (int) right, bottom);
mDivider.draw(c);
} else {
c.drawRect(left, top, right, bottom, mPaint);
}
}
}
示例6: 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();
}
示例7: 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);
}
}
示例8: 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);
}
}
示例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: onDrawOver
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(c, parent, state);
if (!showFloatingHeaderOnScrolling) {
return;
}
int firstVisiblePos = ((LinearLayoutManager) parent.getLayoutManager()).findFirstVisibleItemPosition();
if (firstVisiblePos == RecyclerView.NO_POSITION) {
return;
}
String title = getTitle(firstVisiblePos);
if (TextUtils.isEmpty(title)) {
return;
}
boolean flag = false;
if (getTitle(firstVisiblePos + 1) != null && !title.equals(getTitle(firstVisiblePos + 1))) {
//說明是當前組最後一個元素,但不一定碰撞了
// Log.e(TAG, "onDrawOver: "+"==============" +firstVisiblePos);
View child = parent.findViewHolderForAdapterPosition(firstVisiblePos).itemView;
if (child.getTop() + child.getMeasuredHeight() < mTitleHeight) {
//進一步檢測碰撞
// Log.e(TAG, "onDrawOver: "+child.getTop()+"$"+firstVisiblePos );
c.save();//保存畫布當前的狀態
flag = true;
c.translate(0, child.getTop() + child.getMeasuredHeight() - mTitleHeight);//負的代表向上
}
}
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
int top = parent.getPaddingTop();
int bottom = top + mTitleHeight;
c.drawRect(left, top, right, bottom, mBackgroundPaint);
float x = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, mContext.getResources().getDisplayMetrics());
float y = bottom - (mTitleHeight - mTextHeight) / 2 - mTextBaselineOffset;//計算文字baseLine
c.drawText(title, x, y, mTextPaint);
if (flag) {
//還原畫布為初始狀態
c.restore();
}
}
示例11: 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);
}
}
示例12: drawVerticalLine
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVerticalLine(Canvas c, RecyclerView parent, RecyclerView.State state){
int top = parent.getPaddingTop();
int bottom = parent.getHeight() - parent.getPaddingBottom();
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 left = child.getRight() + params.rightMargin;
final int right = left + mDivider.getIntrinsicWidth();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例13: doClickOtherToNavigation
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void doClickOtherToNavigation(ViewGroup parent, int position, MyViewHolder myHolder) {
RecyclerView recyclerView = (RecyclerView) parent;
LayoutManager manager = recyclerView.getLayoutManager();
View currentView = manager.findViewByPosition(myHolder.getAdapterPosition());
View preTargetView = manager.findViewByPosition(this.mTopSize);
GridLayoutManager gridLayoutManager = (GridLayoutManager) manager;
int spanCount = gridLayoutManager.getSpanCount();
int targetPosition = this.mTopSize + 1;
if (recyclerView.indexOfChild(preTargetView) >= 0) {
int targetX = preTargetView.getLeft();
int targetY = preTargetView.getTop();
if ((targetPosition - 1) % spanCount == 0) {
View targetView = manager.findViewByPosition(targetPosition);
targetX = targetView.getLeft();
targetY = targetView.getTop();
} else {
targetX += preTargetView.getWidth() + UIsUtils.dipToPx(TitleBar.SHAREBTN_RIGHT_MARGIN);
if (gridLayoutManager.findLastVisibleItemPosition() == getItemCount() - 1 && (((getItemCount() - 1) - this.mTopSize) - 2) % spanCount == 0) {
if (gridLayoutManager.findFirstVisibleItemPosition() != 0) {
targetY += preTargetView.getHeight() + UIsUtils.dipToPx(TitleBar.SHAREBTN_RIGHT_MARGIN);
} else if (gridLayoutManager.findFirstCompletelyVisibleItemPosition() != 0) {
targetY += (-recyclerView.getChildAt(0).getTop()) - recyclerView.getPaddingTop();
}
}
}
moveOtherToMy(myHolder);
startAnimation(recyclerView, currentView, (float) targetX, (float) targetY);
return;
}
moveOtherToMy(myHolder);
int index = (this.mTopSize % spanCount) - 1;
if (index < 0) {
index = spanCount - 1;
}
startAnimation(recyclerView, currentView, (float) ((currentView.getWidth() * index) + (index == 0 ? 0 : (index - 1) * UIsUtils.dipToPx(TitleBar.SHAREBTN_RIGHT_MARGIN))), 0.0f);
}
示例14: isStickyHeaderBeingPushedOffscreen
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private boolean isStickyHeaderBeingPushedOffscreen(RecyclerView recyclerView, View stickyHeader) {
View viewAfterHeader = getFirstViewUnobscuredByHeader(recyclerView, stickyHeader);
int firstViewUnderHeaderPosition = recyclerView.getChildAdapterPosition(viewAfterHeader);
if (firstViewUnderHeaderPosition == RecyclerView.NO_POSITION) {
return false;
}
if (firstViewUnderHeaderPosition > 0 && hasNewHeader(firstViewUnderHeaderPosition)) {
View nextHeader = mHeaderProvider.getHeader(recyclerView, firstViewUnderHeaderPosition);
Rect nextHeaderMargins = mDimensionCalculator.getMargins(nextHeader);
Rect headerMargins = mDimensionCalculator.getMargins(stickyHeader);
if (mOrientationProvider.getOrientation(recyclerView) == LinearLayoutManager.VERTICAL) {
int topOfNextHeader = viewAfterHeader.getTop() - nextHeaderMargins.bottom - nextHeader.getHeight() - nextHeaderMargins.top;
int bottomOfThisHeader = recyclerView.getPaddingTop() + stickyHeader.getBottom() + headerMargins.top + headerMargins.bottom;
if (topOfNextHeader < bottomOfThisHeader) {
return true;
}
} else {
int leftOfNextHeader = viewAfterHeader.getLeft() - nextHeaderMargins.right - nextHeader.getWidth() - nextHeaderMargins.left;
int rightOfThisHeader = recyclerView.getPaddingLeft() + stickyHeader.getRight() + headerMargins.left + headerMargins.right;
if (leftOfNextHeader < rightOfThisHeader) {
return true;
}
}
}
return false;
}