public class Zdy_Ls_View extends ViewGroup {
public Zdy_Ls_View(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
measureChildren(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int width = getWidth();
int low = 0;
int diswidth = 18;
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(i);
int mWidth = childAt.getMeasuredWidth();
int mHeight = childAt.getMeasuredHeight();
if (diswidth + mWidth > width) {
low++;
diswidth = 18;
}
childAt.layout(diswidth, low * mHeight, diswidth + mWidth, mHeight * (low + 1));
diswidth += mWidth;
}
}
}