Methods Summary |
---|
public static android.support.v7.widget.OrientationHelper | createHorizontalHelper(RecyclerView.LayoutManager layoutManager)Creates a horizontal OrientationHelper for the given LayoutManager.
return new OrientationHelper(layoutManager) {
@Override
public int getEndAfterPadding() {
return mLayoutManager.getWidth() - mLayoutManager.getPaddingRight();
}
@Override
public int getEnd() {
return mLayoutManager.getWidth();
}
@Override
public void offsetChildren(int amount) {
mLayoutManager.offsetChildrenHorizontal(amount);
}
@Override
public int getStartAfterPadding() {
return mLayoutManager.getPaddingLeft();
}
@Override
public int getDecoratedMeasurement(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedMeasuredWidth(view) + params.leftMargin
+ params.rightMargin;
}
@Override
public int getDecoratedMeasurementInOther(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedMeasuredHeight(view) + params.topMargin
+ params.bottomMargin;
}
@Override
public int getDecoratedEnd(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedRight(view) + params.rightMargin;
}
@Override
public int getDecoratedStart(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedLeft(view) - params.leftMargin;
}
@Override
public int getTotalSpace() {
return mLayoutManager.getWidth() - mLayoutManager.getPaddingLeft()
- mLayoutManager.getPaddingRight();
}
@Override
public void offsetChild(View view, int offset) {
view.offsetLeftAndRight(offset);
}
@Override
public int getEndPadding() {
return mLayoutManager.getPaddingRight();
}
};
|
public static android.support.v7.widget.OrientationHelper | createOrientationHelper(RecyclerView.LayoutManager layoutManager, int orientation)Creates an OrientationHelper for the given LayoutManager and orientation.
switch (orientation) {
case HORIZONTAL:
return createHorizontalHelper(layoutManager);
case VERTICAL:
return createVerticalHelper(layoutManager);
}
throw new IllegalArgumentException("invalid orientation");
|
public static android.support.v7.widget.OrientationHelper | createVerticalHelper(RecyclerView.LayoutManager layoutManager)Creates a vertical OrientationHelper for the given LayoutManager.
return new OrientationHelper(layoutManager) {
@Override
public int getEndAfterPadding() {
return mLayoutManager.getHeight() - mLayoutManager.getPaddingBottom();
}
@Override
public int getEnd() {
return mLayoutManager.getHeight();
}
@Override
public void offsetChildren(int amount) {
mLayoutManager.offsetChildrenVertical(amount);
}
@Override
public int getStartAfterPadding() {
return mLayoutManager.getPaddingTop();
}
@Override
public int getDecoratedMeasurement(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedMeasuredHeight(view) + params.topMargin
+ params.bottomMargin;
}
@Override
public int getDecoratedMeasurementInOther(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedMeasuredWidth(view) + params.leftMargin
+ params.rightMargin;
}
@Override
public int getDecoratedEnd(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedBottom(view) + params.bottomMargin;
}
@Override
public int getDecoratedStart(View view) {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
return mLayoutManager.getDecoratedTop(view) - params.topMargin;
}
@Override
public int getTotalSpace() {
return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop()
- mLayoutManager.getPaddingBottom();
}
@Override
public void offsetChild(View view, int offset) {
view.offsetTopAndBottom(offset);
}
@Override
public int getEndPadding() {
return mLayoutManager.getPaddingBottom();
}
};
|
public abstract int | getDecoratedEnd(android.view.View view)Returns the end of the view including its decoration and margin.
For example, for the horizontal helper, if a View's right is at pixel 200, has 2px right
decoration and 3px right margin, returned value will be 205.
|
public abstract int | getDecoratedMeasurement(android.view.View view)Returns the space occupied by this View in the current orientation including decorations and
margins.
|
public abstract int | getDecoratedMeasurementInOther(android.view.View view)Returns the space occupied by this View in the perpendicular orientation including
decorations and margins.
|
public abstract int | getDecoratedStart(android.view.View view)Returns the start of the view including its decoration and margin.
For example, for the horizontal helper, if a View's left is at pixel 20, has 2px left
decoration and 3px left margin, returned value will be 15px.
|
public abstract int | getEnd()Returns the end position of the layout without taking padding into account.
|
public abstract int | getEndAfterPadding()Returns the end position of the layout after the end padding is removed.
|
public abstract int | getEndPadding()Returns the padding at the end of the layout. For horizontal helper, this is the right
padding and for vertical helper, this is the bottom padding. This method does not check
whether the layout is RTL or not.
|
public abstract int | getStartAfterPadding()Returns the start position of the layout after the start padding is added.
|
public abstract int | getTotalSpace()Returns the total space to layout. This number is the difference between
{@link #getEndAfterPadding()} and {@link #getStartAfterPadding()}.
|
public int | getTotalSpaceChange()Returns the layout space change between the previous layout pass and current layout pass.
Make sure you call {@link #onLayoutComplete()} at the end of your LayoutManager's
{@link RecyclerView.LayoutManager#onLayoutChildren(RecyclerView.Recycler,
RecyclerView.State)} method.
return INVALID_SIZE == mLastTotalSpace ? 0 : getTotalSpace() - mLastTotalSpace;
|
public abstract void | offsetChild(android.view.View view, int offset)Offsets the child in this orientation.
|
public abstract void | offsetChildren(int amount)Offsets all children's positions by the given amount.
|
public void | onLayoutComplete()Call this method after onLayout method is complete if state is NOT pre-layout.
This method records information like layout bounds that might be useful in the next layout
calculations.
mLastTotalSpace = getTotalSpace();
|