コード例 #1
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (DEBUG && DEBUG_LAYOUT) {
      PtrCLog.d(
          LOG_TAG,
          "onMeasure frame: width: %s, height: %s, padding: %s %s %s %s",
          getMeasuredHeight(),
          getMeasuredWidth(),
          getPaddingLeft(),
          getPaddingRight(),
          getPaddingTop(),
          getPaddingBottom());
    }

    if (mHeaderView != null) {
      measureChildWithMargins(mHeaderView, widthMeasureSpec, 0, heightMeasureSpec, 0);
      MarginLayoutParams lp = (MarginLayoutParams) mHeaderView.getLayoutParams();
      mHeaderHeight = mHeaderView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
      mPtrIndicator.setHeaderHeight(mHeaderHeight);
    }

    if (mContent != null) {
      measureContentView(mContent, widthMeasureSpec, heightMeasureSpec);
      if (DEBUG && DEBUG_LAYOUT) {
        MarginLayoutParams lp = (MarginLayoutParams) mContent.getLayoutParams();
        PtrCLog.d(
            LOG_TAG,
            "onMeasure content, width: %s, height: %s, margin: %s %s %s %s",
            getMeasuredWidth(),
            getMeasuredHeight(),
            lp.leftMargin,
            lp.topMargin,
            lp.rightMargin,
            lp.bottomMargin);
        PtrCLog.d(
            LOG_TAG,
            "onMeasure, currentPos: %s, lastPos: %s, top: %s",
            mPtrIndicator.getCurrentPosY(),
            mPtrIndicator.getLastPosY(),
            mContent.getTop());
      }
    }
  }