Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

List layout built with the new TwoWayView API

View SimpleListLayout.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
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.