Esempio n. 1
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (haveScrollbars == false) {
     int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
     super.onMeasure(widthMeasureSpec, expandSpec);
   } else {
     super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   }
 }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);

    super.onMeasure(widthMeasureSpec, heightSpec);
  }
  @Override
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // HACK! TAKE THAT ANDROID!
    if (isExpanded()) {
      // Calculate entire height by providing a very large height hint.
      // But do not use the highest 2 bits of this integer; those are
      // reserved for the MeasureSpec mode.
      int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
      super.onMeasure(widthMeasureSpec, expandSpec);

      ViewGroup.LayoutParams params = getLayoutParams();
      params.height = getMeasuredHeight();
    } else {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }
Esempio n. 4
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int newHeight = 0;
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    if (heightMode != MeasureSpec.EXACTLY) {
      ListAdapter listAdapter = getAdapter();
      if (listAdapter != null && !listAdapter.isEmpty()) {
        int listPosition = 0;
        for (listPosition = 0;
            listPosition < listAdapter.getCount() && listPosition < MAXIMUM_LIST_ITEMS_VIEWABLE;
            listPosition++) {
          View listItem = listAdapter.getView(listPosition, null, this);
          // now it will not throw a NPE if listItem is a ViewGroup instance
          if (listItem instanceof ViewGroup) {
            listItem.setLayoutParams(
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
          }
          listItem.measure(widthMeasureSpec, heightMeasureSpec);
          newHeight += listItem.getMeasuredHeight();
        }
        newHeight += getDividerHeight() * listPosition;
      }
      if ((heightMode == MeasureSpec.AT_MOST) && (newHeight > heightSize)) {
        if (newHeight > heightSize) {
          newHeight = heightSize;
        }
      }
    } else {
      newHeight = getMeasuredHeight();
    }
    setMeasuredDimension(getMeasuredWidth(), newHeight);
  }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (!mBlockLayoutAndMeasure) {
     super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   } else {
     setMeasuredDimension(getWidth(), getHeight());
   }
 }
 @Override
 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int heightMeasureSpec_custom =
       MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
   super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
   ViewGroup.LayoutParams params = getLayoutParams();
   params.height = getMeasuredHeight();
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (months.isEmpty()) {
     throw new IllegalStateException(
         "Must have at least one month to display.  Did you forget to call init()?");
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
Esempio n. 8
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (mHeaderView != null) {
     measureChild(mHeaderView, widthMeasureSpec, heightMeasureSpec);
     mHeaderViewWidth = mHeaderView.getMeasuredWidth();
     mHeaderViewHeight = mHeaderView.getMeasuredHeight();
   }
 }
Esempio n. 9
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (scrollBarPanel != null && getAdapter() != null) {
      this.widthMeasureSpec = widthMeasureSpec;
      this.heightMeasureSpec = heightMeasureSpec;
      measureChild(scrollBarPanel, widthMeasureSpec, heightMeasureSpec);
    }
  }
Esempio n. 10
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int width = getMeasuredWidth();
   int height = 0;
   ListAdapter adapter = getAdapter();
   int count = adapter.getCount();
   for (int i = 0; i < count; i++) {
     View childView = adapter.getView(i, null, this);
     childView.measure(
         MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
         MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
     height += childView.getMeasuredHeight();
   }
   Rect bgPadding = new Rect();
   getBackground().getPadding(bgPadding);
   height += (count - 1) * getDividerHeight() + bgPadding.top + bgPadding.bottom;
   setMeasuredDimension(width, height);
 }
Esempio n. 11
0
  /** 该函数确定图片存放在View里面的范围 */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    Log.d("zzw", "onMeasure:" + numColumns + " " + horizontalSpacing);

    if (numColumns != 0) {
      columnsWidth =
          (getMeasuredWidth()
                  - getPaddingLeft()
                  - getPaddingRight()
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.marginleft)
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.item_border)
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.head_width)
                  - numColumns * 2 * horizontalSpacing)
              / numColumns;
      Log.d("zzw", "onMeasure:" + columnsWidth);
      if (mCommunityAdapter != null) {
        ((AdpCommunityListView) mCommunityAdapter).setColumnsWidth(columnsWidth);
      }
    }
  }
Esempio n. 12
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
Esempio n. 13
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   // TODO Auto-generated method stub
   int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
   super.onMeasure(widthMeasureSpec, expandSpec);
 }
  @Override
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);
  }
Esempio n. 15
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int maxWidth = meathureWidthByChilds() + getPaddingLeft() + getPaddingRight();
   super.onMeasure(MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.EXACTLY), heightMeasureSpec);
 }
 @Override
 protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   determineColumns();
 }
 @Override
 /** 重写该方法,达到使ListView适应ScrollView的效果 */
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
   super.onMeasure(widthMeasureSpec, expandSpec);
 }