コード例 #1
0
  private void layoutGridHeaderFooter(
      final View child,
      final int position,
      final boolean flowDown,
      final int childrenLeft,
      final int childTop,
      final int childRight,
      final int childBottom) {
    // offset the top and bottom of all our columns
    // if it's the footer we want it below the lowest child bottom
    int gridChildTop;
    int gridChildBottom;

    if (flowDown) {
      gridChildTop = getLowestPositionedBottom();
      gridChildBottom = gridChildTop + getChildHeight(child);
    } else {
      gridChildBottom = getHighestPositionedTop();
      gridChildTop = gridChildBottom - getChildHeight(child);
    }

    for (int i = 0; i < mColumnCount; i++) {
      updateColumnTopIfNeeded(i, gridChildTop);
      updateColumnBottomIfNeeded(i, gridChildBottom);
    }

    super.onLayoutChild(
        child, position, flowDown, childrenLeft, gridChildTop, childRight, gridChildBottom);
  }