Exemplo n.º 1
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
    int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
    int tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);

    int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
    int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
    int tmpWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);

    // fixed scrollview height problems
    if (heightMode == MeasureSpec.UNSPECIFIED
        && getParent() != null
        && (getParent() instanceof ScrollView)) {
      int baseHeight = 0;
      Context context = getContext();
      if (context instanceof Activity) {
        Activity act = (Activity) context;
        int measuredHeight = act.findViewById(android.R.id.content).getMeasuredHeight();
        baseHeight = measuredHeight;
      } else {
        baseHeight = getScreenHeight();
      }
      tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(baseHeight, heightMode);
    }

    mPercentLayoutHelper.adjustChildren(tmpWidthMeasureSpec, tmpHeightMeasureSpec);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (mPercentLayoutHelper.handleMeasuredStateTooSmall()) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }
Exemplo n.º 2
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   mPercentLayoutHelper.adjustChildren(widthMeasureSpec, heightMeasureSpec);
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (mPercentLayoutHelper.handleMeasuredStateTooSmall()) {
     super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   }
 }
Exemplo n.º 3
0
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);

      // Re-measure if we went beyond our maximum size.
      if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) {
        super.onMeasure(
            MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY),
            heightMeasureSpec);
      }
    }
Exemplo n.º 4
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (mCollapsed && addFlag) {
     super.onMeasure(widthMeasureSpec, mHeight);
     return;
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   // 如果展开
   if (mCollapsed) {
     mHeight = getMeasuredHeight();
   }
 }
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);

    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    int prefWidth = this.tnContainer.getPreferredWidth();
    int prefHeight = this.tnContainer.getPreferredHeight();

    if (prefWidth > 0
        && (widthMode == MeasureSpec.UNSPECIFIED
            || widthMode == MeasureSpec.AT_MOST
            || widthMode == MeasureSpec.EXACTLY)) {
      if (widthSize > 0 && prefWidth > widthSize) prefWidth = widthSize;

      widthMeasureSpec = MeasureSpec.makeMeasureSpec(prefWidth, MeasureSpec.EXACTLY);
    }

    if (prefHeight > 0
        && (heightMode == MeasureSpec.UNSPECIFIED
            || heightMode == MeasureSpec.AT_MOST
            || heightMode == MeasureSpec.EXACTLY)) {
      if (heightSize > 0 && prefHeight > heightSize) prefHeight = heightSize;

      heightMeasureSpec = MeasureSpec.makeMeasureSpec(prefHeight, MeasureSpec.EXACTLY);
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
Exemplo n.º 6
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    LogUtil.i("MoveLinearLayout", "[onMeasure] start");
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int count = getChildCount();
    boolean sub2 = false, sub3 = false;
    View view;
    for (int i = 0; i < count; ++i) {
      view = getChildAt(i);

      if (view.getId() == R.id.sub_view_1) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] sub_view_1  widthMeasureSpec : " + widthMeasureSpec);
      }
      if (view.getId() == R.id.sub_view_2 && !sub2) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] sub_view_2  widthMeasureSpec : " + widthMeasureSpec);
        view.setLayoutParams(new LayoutParams(widthMeasureSpec, view.getLayoutParams().height));
        sub2 = true;
      }
      if (view.getId() == R.id.sub_view_3 && sub3 == false) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] : sub_view_3 widthMeasureSpec : " + widthMeasureSpec);
        view.setLayoutParams(new LayoutParams(widthMeasureSpec, view.getLayoutParams().height));
        sub3 = true;
      }
      if (sub2 && sub3) {
        break;
      }
    }
  }
Exemplo n.º 7
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int width = MeasureSpec.getSize(widthMeasureSpec);

    switch (widthMode) {
      case MeasureSpec.AT_MOST:
        // If there is an upper limit, don't exceed maximum width (explicit
        // or implicit)
        if (mMaxWidth > 0) {
          width = Math.min(mMaxWidth, width);
        } else {
          width = Math.min(getPreferredWidth(), width);
        }
        break;
      case MeasureSpec.EXACTLY:
        // If an exact width is specified, still don't exceed any specified
        // maximum width
        if (mMaxWidth > 0) {
          width = Math.min(mMaxWidth, width);
        }
        break;
      case MeasureSpec.UNSPECIFIED:
        // Use maximum width, if specified, else preferred width
        width = mMaxWidth > 0 ? mMaxWidth : getPreferredWidth();
        break;
    }
    widthMode = MeasureSpec.EXACTLY;
    super.onMeasure(MeasureSpec.makeMeasureSpec(width, widthMode), heightMeasureSpec);
  }
Exemplo n.º 8
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int width = MeasureSpec.getSize(widthMeasureSpec);
   int height = MeasureSpec.getSize(heightMeasureSpec);
   //        int width2 = getDefaultSize(0, widthMeasureSpec);
   //        int height2 = getDefaultSize(0, heightMeasureSpec);
   int childCount = getChildCount();
   int finalHeight = 0;
   for (int i = 0; i < childCount; i++) {
     View child = getChildAt(i);
     LayoutParams margins = (LayoutParams) child.getLayoutParams();
     int topMargin = margins.topMargin;
     int bottomMargin = margins.bottomMargin;
     int leftMargin = margins.leftMargin;
     int rightMargin = margins.rightMargin;
     if (child.getVisibility() != View.GONE) {
       final int childWidthMeasureSpec =
           getChildMeasureSpec(widthMeasureSpec, 0, width - leftMargin - rightMargin);
       final int childHeightMeasureSpec =
           getChildMeasureSpec(heightMeasureSpec, 0, height - topMargin - bottomMargin);
       measureChild(child, childWidthMeasureSpec, childHeightMeasureSpec);
       finalHeight += child.getMeasuredHeight();
     }
   }
   setMeasuredDimension(width, finalHeight);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(
       widthMeasureSpec,
       MeasureSpec.makeMeasureSpec(
           MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED));
 }
Exemplo n.º 10
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   // TODO Auto-generated method stub
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   mRevealLayoutr = MeasureSpec.getSize(widthMeasureSpec);
   mRevealLayoutb = MeasureSpec.getSize(heightMeasureSpec);
 }
Exemplo n.º 11
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    // int size = MeasureSpec.getSize(heightMeasureSpec);
    // int mode = MeasureSpec.getMode(heightMeasureSpec);
    // LogManager.d("size" + size + "mode" + mode);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
   int parentHeight = (parentWidth / 16) * 9;
   heightMeasureSpec = (widthMeasureSpec / 16) * 9;
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   this.setMeasuredDimension(parentWidth, parentHeight);
 }
Exemplo n.º 13
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (isSetList) {
     mIndexListSize = mAlphabetList.size();
     addTextView();
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   measureChild(
       mContentView,
       widthMeasureSpec,
       MeasureSpec.makeMeasureSpec(
           MeasureSpec.getSize(heightMeasureSpec) - getNavViewHeight(), MeasureSpec.EXACTLY));
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
   if (mMaxWidth > 0 && mMaxWidth < measuredWidth) {
     int measureMode = MeasureSpec.getMode(widthMeasureSpec);
     widthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxWidth, measureMode);
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int mode = MeasureSpec.getMode(widthMeasureSpec);
   int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
   // int adjustedMaxWidth = (int) Utils.getDensitySize(MAX_WIDTH);
   int adjustedMaxWidth = MAX_WIDTH;
   int adjustedWidth = Math.min(measuredWidth, adjustedMaxWidth);
   int adjustedWidthMeasureSpec = MeasureSpec.makeMeasureSpec(adjustedWidth, mode);
   super.onMeasure(adjustedWidthMeasureSpec, heightMeasureSpec);
 }
Exemplo n.º 17
0
  @SuppressWarnings("unused")
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));

    int childWidthSize = getMeasuredWidth();
    int childHeightSize = (int) ((float) childWidthSize / 2);
    widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
    heightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
 protected void onMeasure(int paramInt1, int paramInt2)
 {
   int i = View.MeasureSpec.getSize(paramInt1);
   if (a)
   {
     if ((i > b) && (a())) {
       a(false);
     }
     b = i;
   }
   int j;
   if ((!a()) && (View.MeasureSpec.getMode(paramInt1) == 1073741824))
   {
     j = View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE);
     i = 1;
   }
   for (;;)
   {
     super.onMeasure(j, paramInt2);
     j = i;
     if (a)
     {
       j = i;
       if (!a())
       {
         j = i;
         if ((getMeasuredWidthAndState() & 0xFF000000) == 16777216)
         {
           a(true);
           j = 1;
         }
       }
     }
     if (j != 0) {
       super.onMeasure(paramInt1, paramInt2);
     }
     return;
     i = 0;
     j = paramInt1;
   }
 }
Exemplo n.º 19
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (mIconView != null && mPreserveIconSpacing) {
     // Enforce minimum icon spacing
     ViewGroup.LayoutParams lp = getLayoutParams();
     LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
     if (lp.height > 0 && iconLp.width <= 0) {
       iconLp.width = lp.height;
     }
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
Exemplo n.º 20
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int width = MeasureSpec.getSize(widthMeasureSpec);
   int childCount = getChildCount();
   int finalHeight = 0;
   for (int i = 0; i < childCount; i++) {
     View child = getChildAt(i);
     if (child.getVisibility() == View.VISIBLE) {
       measureChild(child, widthMeasureSpec, heightMeasureSpec);
       finalHeight += child.getMeasuredHeight();
     }
   }
   setMeasuredDimension(width, finalHeight);
 }
Exemplo n.º 21
0
  /* Stolen from PhoneWindow */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int width = getMeasuredWidth();
    boolean measure = false;

    widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);

    final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;

    if (tv.type != TypedValue.TYPE_NULL) {
      final int min;
      if (tv.type == TypedValue.TYPE_DIMENSION) {
        min = (int) tv.getDimension(metrics);
      } else if (tv.type == TypedValue.TYPE_FRACTION) {
        min = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
      } else {
        min = 0;
      }

      if (width < min) {
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
        measure = true;
      }
    }

    // TODO: Support height?

    if (measure) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }
Exemplo n.º 22
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (mWeight > 0 && mContent.getVisibility() == VISIBLE) {
     View parent = (View) getParent();
     if (parent != null) {
       if (mOrientation == VERTICAL) {
         heightMeasureSpec =
             MeasureSpec.makeMeasureSpec(
                 (int) (parent.getHeight() * mWeight), MeasureSpec.EXACTLY);
       } else {
         widthMeasureSpec =
             MeasureSpec.makeMeasureSpec((int) (parent.getWidth() * mWeight), MeasureSpec.EXACTLY);
       }
     }
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (LayoutParams.WRAP_CONTENT == getLayoutParams().height) {
     getLayoutParams().height = (int) mBannerHeight;
   } else {
     mBannerHeight = getHeight();
   }
   if (isInEditMode()) {
     setBackgroundColor(Color.GRAY);
     return;
   }
   if (mFirstView != null) {
     mFirstView.getLayoutParams().height = (int) mBannerHeight;
   }
   if (mSecondView != null) {
     mSecondView.getLayoutParams().height = (int) mBannerHeight;
   }
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int height = mSeparatorDrawable.getIntrinsicHeight();
   if (getMeasuredHeight() < height) {
     // This should only be an issue if there are currently no separators
     // showing; i.e. if there is one crumb and no back button.
     int mode = View.MeasureSpec.getMode(heightMeasureSpec);
     switch (mode) {
       case View.MeasureSpec.AT_MOST:
         if (View.MeasureSpec.getSize(heightMeasureSpec) < height) {
           return;
         }
         break;
       case View.MeasureSpec.EXACTLY:
         return;
       default:
         break;
     }
     setMeasuredDimension(getMeasuredWidth(), height);
   }
 }
Exemplo n.º 25
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   calculateIndicatorPos();
 }
Exemplo n.º 26
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   // TODO Auto-generated method stub
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
Exemplo n.º 27
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   setMeasuredDimension(getMeasuredWidth(), (int) (getMeasuredWidth() * widthRatio));
 }
Exemplo n.º 28
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   Log.d(TAG, "onMeasure ");
 }
Exemplo n.º 29
0
 public void onMeasure(int paramInt1, int paramInt2) {
   super.onMeasure(
       View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(paramInt1), MeasureSpec.EXACTLY),
       View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(paramInt2), MeasureSpec.EXACTLY));
 }