本文整理匯總了Java中android.support.v7.widget.RecyclerView.getClipToPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getClipToPadding方法的具體用法?Java RecyclerView.getClipToPadding怎麽用?Java RecyclerView.getClipToPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getClipToPadding方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent, View child) {
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();
}
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();
}
示例2: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void drawHorizontal(Canvas canvas, RecyclerView parent, View child) {
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();
}
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();
}
示例3: draw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi") private void draw(Canvas canvas, RecyclerView parent, View child) {
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();
}
parent.getDecoratedBoundsWithMargins(child, mBounds);
final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
final int top = bottom - 16;
canvas.drawRect(left, top, right, bottom, myPaint);
canvas.restore();
}
示例4: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent, View child) {
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();
}
parent.getDecoratedBoundsWithMargins(child, mBounds);
final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
final int top = bottom - mDivider.getIntrinsicHeight() * 4;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
canvas.restore();
}
示例5: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
protected 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();
}
示例6: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
protected 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包/類
@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包/類
@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++) {
// Remove the last divider
// @By_syk
for (int i = 0; i < childCount - 1; 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();
}
示例9: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void drawVertical(Canvas canvas, RecyclerView parent) {
canvas.save();
int left;
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();
}
if(mDividerPadding > 0){//設置了padding,調整left和right的值
left = left + mDividerPadding;
right = right - mDividerPadding;
}
mDivider.setColor(mDividerColor);//自定義color,沒設置就用默認值
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
parent.getDecoratedBoundsWithMargins(child, mBounds);
int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
int top = bottom - mDivider.getIntrinsicHeight();
if(mVerticalDividerHeight > 0){//如果設置了高度,調整top的值
top = bottom - mVerticalDividerHeight;
}
mDivider.setBounds(left, top, right, bottom);
//mDivider.setCornerRadius();//設置矩形圓角
mDivider.draw(canvas);
}
canvas.restore();
}
示例10: drawHorizontal
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
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();
}
if(mDividerPadding > 0){
top = top + mDividerPadding;
bottom = bottom - mDividerPadding;
}
mDivider.setColor(mDividerColor);
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child));
int left = right - mDivider.getIntrinsicWidth();
if(mHorizontalDividerWidth > 0){
left = right - mHorizontalDividerWidth;
}
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
canvas.restore();
}
示例11: 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();
}
示例12: onDrawOver
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)
{
super.onDrawOver(c, parent, state);
if(parent.getLayoutManager() == null)
{
return;
}
if(parent.getClipToPadding())
{
c.clipRect(parent.getPaddingLeft() - dividerOffset,
parent.getPaddingTop() - dividerOffset,
parent.getWidth() - parent.getPaddingRight() + dividerOffset,
parent.getHeight() - parent.getPaddingBottom() + dividerOffset);
}
if(orientation == HORIZONTAL)
{
drawHorizontal(c, parent);
}
else
{
drawVertical(c, parent);
}
}
示例13: onDraw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
if (parent.getLayoutManager() == null) {
return;
}
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);
Object object = child.getTag(R.id.item_divider);
if (object != null && object instanceof Drawable) {
Drawable drawable = (Drawable) object;
final int top = mBounds.top + Math.round(child.getTranslationX());
final int bottom = mBounds.top + drawable.getIntrinsicHeight();
drawable.setBounds(left, top, right, bottom);
drawable.draw(canvas);
}
}
canvas.restore();
}
示例14: draw
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void draw(Canvas c, RecyclerView parent)
{
int childCount = parent.getChildCount();
if(parent.getClipToPadding())
{
c.clipRect(parent.getPaddingLeft(), parent.getPaddingTop(),
parent.getWidth() - parent.getPaddingRight(),
parent.getHeight() - parent.getPaddingBottom());
}
int top = parent.getPaddingTop();
int preHeaderId;
int headerId = NO_POSITION;
int x = parent.getPaddingLeft();
for(int i = 0; i < childCount; i++)
{
View itemView = parent.getChildAt(i);
int position = parent.getChildAdapterPosition(itemView);
//隻有各組第一個 並且 headerId!=-1 才繪製頭部view
preHeaderId = headerId;
headerId = getHeaderId(position);
if(headerId <= NO_POSITION || headerId == preHeaderId)
{
continue;
}
View header = getHeaderView(parent, position);
int heightWithPadding = header.getHeight() + top;
int y = Math.max(heightWithPadding, itemView.getTop());
if(isStick)
{
int nextPosition = getNextHeadPosition(i, headerId, childCount, parent);
if(nextPosition != NO_POSITION)
{
View nextView = parent.getChildAt(nextPosition);
//獲得真實位置後再進行判斷
parent.getDecoratedBoundsWithMargins(nextView, rect);
//判斷下一個頭部view是否到了與上一個頭部view接觸的臨界值
//如果滿足條件則把上一個頭部view推上去
if(rect.top <= heightWithPadding)
{
//這裏使用nextView.getTop 直接減掉 header.getHeight(),如果減去heightWithPadding,
//會出現移動時的間距
y = nextView.getTop() - header.getHeight();
}
}
}
//這個時候,y是header底部位置,需要減去它的高度,修正定位
y -= header.getHeight();
c.translate(x, y);
header.draw(c);
//修正回來
c.translate(-x, -y);
}
}