Example #1
0
  /**
   * This is called with the full window width and height to allow stack view children to perform
   * the full screen transition down.
   */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    // 可见区域
    Rect _taskStackBounds = new Rect();
    mConfig.getTaskStackBounds(
        width, height, mConfig.systemInsets.top, mConfig.systemInsets.right, _taskStackBounds);

    setStackInsetRect(_taskStackBounds);

    // Compute our stack/task rects
    //        Rect taskStackBounds = new Rect(mTaskStackBounds);
    //        taskStackBounds.bottom -= mConfig.systemInsets.bottom;

    computeRects(
        width, height, _taskStackBounds, mConfig.launchedWithAltTab, mConfig.launchedFromHome);

    // If this is the first layout, then scroll to the front of the stack and synchronize the
    // stack views immediately to load all the views
    if (mAwaitingFirstLayout) {
      mStackScroller.setStackScrollToInitialState();
      //            requestSynchronizeStackViewsWithModel();
      //            synchronizeStackViewsWithModel();
    }

    // Measure each of the TaskViews
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
      DeckChildView tv = (DeckChildView) getChildAt(i);
      //            if (tv.getBackground() != null) {
      //                tv.getBackground().getPadding(mTmpRect);
      //            } else {
      //                mTmpRect.setEmpty();
      //            }
      tv.measure(
          MeasureSpec.makeMeasureSpec(
              mLayoutAlgorithm.mTaskRect.width() + mTmpRect.left + mTmpRect.right,
              MeasureSpec.EXACTLY),
          MeasureSpec.makeMeasureSpec(
              mLayoutAlgorithm.mTaskRect.height() + mTmpRect.top + mTmpRect.bottom,
              MeasureSpec.EXACTLY));

      //            tv.measure(
      //                    widthMeasureSpec,
      //                    heightMeasureSpec);
    }

    setMeasuredDimension(width, height);
  }