Skip to content

@lucasr /SimpleListLayout.java
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
List layout built with the new TwoWayView API
public class SimpleListLayout extends TwoWayLayoutManager {
public SimpleListLayout(Context context, Orientation orientation) {
super(context, orientation);
}
@Override
protected void measureChild(View child, Direction direction) {
measureChildWithMargins(child, 0, 0);
}
@Override
protected void layoutChild(View child, Direction direction) {
final int width = getDecoratedMeasuredWidth(child);
final int height = getDecoratedMeasuredHeight(child);
final int l, t, r, b;
if (getOrientation() == Orientation.VERTICAL) {
l = getPaddingLeft();
t = direction == Direction.END ? getLayoutEnd() : getLayoutStart() - height;
} else {
l = direction == Direction.END ? getLayoutEnd() : getLayoutStart() - width;
t = getPaddingTop();
}
r = l + width;
b = t + height;
layoutDecorated(child, l, t, r, b);
}
@Override
protected boolean canAddMoreViews(Direction direction, int limit) {
if (direction == Direction.END) {
return getLayoutEnd() < getEndWithPadding();
} else {
return getLayoutStart() > getStartWithPadding();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.