Let's take a look,
There are some differences in the layout effect implemented in ". The height of each grid is irregular, that is, the legendary waterfall flow layout. Generally, this effect can be achieved by using third-party controls, if the image is not loaded, it can be directly written in xml for implementation, but there will be a lot of code;
The following is the full code of the custom viewgroup:
WaterfullLayout String tag = "balance" columns = 2 rows = 0 margin = 10 count = 0 mMaxChildWidth = 0 mMaxChildHeight = 0 WaterfullLayout (Context context, AttributeSet attrs, (attrs! ===. GetInteger (R. styleable. myGridLayout_numColumns, 2 = (). getInteger (R. styleable. myGridLayout_itemMargin, 2 (context, attrs, 0 onMeasure (widthMeasureSpec, = 0 = 0 = (count = 0 = count % columns = 0? Count/columns: count/columns + 1; top [] = (I = 0; I <rows; I ++) {(j = 0; j <columns; j ++) {View child =. getChildAt (I * columns + (child = (child. getVisibility () = + = lp. height + = + onLayout (changed, l, t, r, height = B-t; width = r-l; (count = 0 gridW = (width-margin * (columns + 1)/columns; gridH = 0; left = 0 top [] = (I = 0; I <rows; I ++) {(j = 0; j <columns; j ++ ){ View child =. getChildAt (I * columns + (child = (child. getTag ()! = &-= GetMax (top)-= j * gridW + margin * (j + 1 + margin, left ++ = j * gridW + margin * (j + 1 + = + gridW, top [j] ++ = getMax (max = array [0 (I = 0; I <array. length; I ++ (max <=View Code