Java Code Examples for android.view.View.measure()

The following are Jave code examples for showing how to use measure() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: browser   File: SuperListView.java   View Source Code Vote up 7 votes
private int measureHeight(int measureSpec) {
	int mode = MeasureSpec.getMode(measureSpec);
	if (mode == MeasureSpec.AT_MOST) {
		return MeasureSpec.makeMeasureSpec(measureSpec, mode);
	} else if (mode == MeasureSpec.EXACTLY) {
		ListAdapter adapter = getAdapter();
		if (adapter == null) {
			measureSpec = 0;
		} else {
			int result = 0;
			for (int i = 0; i < adapter.getCount(); i++) {
				View contentView = adapter.getView(i, null, null);
				contentView.measure(0, 0);
				result += contentView.getMeasuredHeight();
			}
			measureSpec = result + getDividerHeight()
					* (adapter.getCount() - 1);
		}
	}

	return MeasureSpec.makeMeasureSpec(measureSpec, mode);
}
 
Example 2
Project: CSipSimple   File: ActivityChooserView.java   View Source Code Vote up 7 votes
public int measureContentWidth() {
    // The user may have specified some of the target not to be shown but we
    // want to measure all of them since after expansion they should fit.
    final int oldMaxActivityCount = mMaxActivityCount;
    mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED;

    int contentWidth = 0;
    View itemView = null;

    final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int count = getCount();

    for (int i = 0; i < count; i++) {
        itemView = getView(i, itemView, null);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth());
    }

    mMaxActivityCount = oldMaxActivityCount;

    return contentWidth;
}
 
Example 3
Project: yyox   File: ExpandedListUtils.java   View Source Code Vote up 7 votes
public static void setExpandedListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height += appendHeight;
    listView.setLayoutParams(params);
}
 
Example 4
Project: NeoTerm   File: PreviewDataBinder.java   View Source Code Vote up 7 votes
@Nullable
@Override
protected final Bitmap doInBackground(@NonNull final Tab key,
                                      @NonNull final TabItem... params) {
    TabItem tabItem = params[0];
    PhoneTabViewHolder viewHolder = tabItem.getViewHolder();
    View child = viewHolder.child;
    viewHolder.child = null;
    int width = parent.getWidth();
    int height = parent.getHeight();
    child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    child.draw(canvas);
    return bitmap;
}
 
Example 5
Project: buildAPKsSamples   File: FixedGridLayout.java   View Source Code Vote up 6 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int cellWidthSpec = MeasureSpec.makeMeasureSpec(mCellWidth,
            MeasureSpec.AT_MOST);
    int cellHeightSpec = MeasureSpec.makeMeasureSpec(mCellHeight,
            MeasureSpec.AT_MOST);

    int count = getChildCount();
    for (int index=0; index<count; index++) {
        final View child = getChildAt(index);
        child.measure(cellWidthSpec, cellHeightSpec);
    }
    // Use the size our parents gave us
    setMeasuredDimension(resolveSize(mCellWidth*count, widthMeasureSpec),
            resolveSize(mCellHeight*count, heightMeasureSpec));
}
 
Example 6
Project: AndroidBackendlessChat   File: DialogUtils.java   View Source Code Vote up 6 votes
/** A popup to select the type of message to send, "Text", "Image", "Location".*/
public static PopupWindow getMenuOptionPopup(Context context, View.OnClickListener listener){
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View popupView = inflater.inflate(R.layout.chat_sdk_popup_options, null);
    PopupWindow optionPopup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
    popupView.findViewById(R.id.chat_sdk_btn_choose_picture).setOnClickListener(listener);
    popupView.findViewById(R.id.chat_sdk_btn_take_picture).setOnClickListener(listener);
    popupView.findViewById(R.id.chat_sdk_btn_location).setOnClickListener(listener);

    if (!BDefines.Options.LocationEnabled || context.getString(R.string.google_maps_api_key).isEmpty()){
        popupView.findViewById(R.id.chat_sdk_btn_location).setVisibility(View.GONE);
    }
    
    popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    // TODO fix popup size to wrap view size.
    optionPopup.setContentView(popupView);
    optionPopup.setBackgroundDrawable(new BitmapDrawable());
    optionPopup.setOutsideTouchable(true);
    optionPopup.setWidth(popupView.getMeasuredWidth());
    optionPopup.setHeight(popupView.getMeasuredHeight());
    return optionPopup;
}
 
Example 7
Project: RNLearn_Project1   File: FlatNativeViewHierarchyManager.java   View Source Code Vote up 6 votes
/**
 * Updates View bounds, possibly re-measuring and re-layouting it if the size changed.
 *
 * @param reactTag reactTag to lookup a View by
 * @param left left coordinate relative to parent
 * @param top top coordinate relative to parent
 * @param right right coordinate relative to parent
 * @param bottom bottom coordinate relative to parent
 */
/* package */ void updateViewBounds(int reactTag, int left, int top, int right, int bottom) {
  View view = resolveView(reactTag);
  int width = right - left;
  int height = bottom - top;
  if (view.getWidth() != width || view.getHeight() != height) {
    // size changed, we need to measure and layout the View
    view.measure(
        MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(left, top, right, bottom);
  } else {
    // same size, only location changed, there is a faster route.
    view.offsetLeftAndRight(left - view.getLeft());
    view.offsetTopAndBottom(top - view.getTop());
  }
}
 
Example 8
Project: PlusGram   File: SectionsListView.java   View Source Code Vote up 6 votes
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
    if (header.isLayoutRequested() || forceLayout) {
        int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
        int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        try {
            header.measure(widthSpec, heightSpec);
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
        header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
    }
}
 
Example 9
Project: XDanmuku   File: DanmuAdapter.java   View Source Code Vote up 6 votes
@Override
    public int getSingleLineHeight() {
        //将所有类型弹幕的布局拿出来,找到高度最大值,作为弹道高度
        View view = LayoutInflater.from(context).inflate(R.layout.item_danmu, null);
        //指定行高
        view.measure(0, 0);

        View view2 = LayoutInflater.from(context).inflate(R.layout.item_super_danmu, null);
        //指定行高
        view2.measure(0, 0);

//        return Math.max(view.getMeasuredHeight(),view2.getMeasuredHeight());
        return view.getMeasuredHeight();
    }
 
Example 10
Project: mupdf-android-viewer-old   File: ReaderView.java   View Source Code Vote up 6 votes
private void measureView(View v) {
	// See what size the view wants to be
	v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

	if (!mReflow) {
	// Work out a scale that will fit it to this view
	float scale = Math.min((float)getWidth()/(float)v.getMeasuredWidth(),
				(float)getHeight()/(float)v.getMeasuredHeight());
	// Use the fitting values scaled by our current scale factor
	v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()*scale*mScale),
			View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()*scale*mScale));
	} else {
		v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()),
				View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()));
	}
}
 
Example 11
Project: letv   File: PullToRefreshBase.java   View Source Code Vote up 6 votes
private void measureView(View child) {
    int childHeightSpec;
    ViewGroup.LayoutParams p = child.getLayoutParams();
    if (p == null) {
        p = new ViewGroup.LayoutParams(-1, -2);
    }
    int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
    int lpHeight = p.height;
    if (lpHeight > 0) {
        childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
    } else {
        childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
    }
    child.measure(childWidthSpec, childHeightSpec);
}
 
Example 12
Project: boohee_v5.6   File: RecyclerView.java   View Source Code Vote up 6 votes
public void measureChildWithMargins(View child, int widthUsed, int heightUsed) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    Rect insets = this.mRecyclerView.getItemDecorInsetsForChild(child);
    heightUsed += insets.top + insets.bottom;
    int widthSpec = getChildMeasureSpec(getWidth(), getWidthMode(), (((getPaddingLeft() + getPaddingRight()) + lp.leftMargin) + lp.rightMargin) + (widthUsed + (insets.left + insets.right)), lp.width, canScrollHorizontally());
    int heightSpec = getChildMeasureSpec(getHeight(), getHeightMode(), (((getPaddingTop() + getPaddingBottom()) + lp.topMargin) + lp.bottomMargin) + heightUsed, lp.height, canScrollVertically());
    if (shouldMeasureChild(child, widthSpec, heightSpec, lp)) {
        child.measure(widthSpec, heightSpec);
    }
}
 
Example 13
Project: vlayout   File: RangeStyle.java   View Source Code Vote up 6 votes
public void bindLayoutView(@NonNull final View layoutView) {
    layoutView.measure(View.MeasureSpec.makeMeasureSpec(mLayoutRegion.width(), View.MeasureSpec.EXACTLY),
        View.MeasureSpec.makeMeasureSpec(mLayoutRegion.height(), View.MeasureSpec.EXACTLY));
    layoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
    layoutView.setBackgroundColor(mBgColor);

    if (mLayoutViewBindListener != null) {
        mLayoutViewBindListener.onBind(layoutView, getLayoutHelper());
    }

    // reset region rectangle
    mLayoutRegion.set(0, 0, 0, 0);
}
 
Example 14
Project: RefreshWithAppBarLayout   File: WithBottomContentView.java   View Source Code Vote up 6 votes
/**
 * 设置布局内容
 */
@Override
protected FrameLayout createRefreshableView(Context context, AttributeSet attrs) {
    FrameLayout frameLayout = new FrameLayout(context);
    View v = LayoutInflater.from(context).inflate(R.layout.activity_with_bottom_tab_content, null);
    v.measure(View.MeasureSpec.AT_MOST, View.MeasureSpec.AT_MOST);
    frameLayout.addView(v);
    return frameLayout;
}
 
Example 15
Project: AdaptiveTableLayout   File: AdaptiveTableLayout.java   View Source Code Vote up 5 votes
@SuppressWarnings("unused")
private void addViewHolder(int row, int column, int itemType) {
    boolean createdNewView;
    // need to add new one
    ViewHolder viewHolder = mRecycler.popRecycledViewHolder(itemType);
    createdNewView = viewHolder == null;
    if (createdNewView) {
        viewHolder = createViewHolder(itemType);
    }

    if (viewHolder == null) {
        return;
    }

    // prepare view holder
    viewHolder.setRowIndex(row);
    viewHolder.setColumnIndex(column);
    viewHolder.setItemType(itemType);
    View view = viewHolder.getItemView();

    view.setTag(R.id.tag_view_holder, viewHolder);
    // add view to the layout
    addView(view, 0);

    // save and measure view holder
    if (itemType == ViewHolderType.ITEM) {
        mViewHolders.put(row, column, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindViewHolder(viewHolder, row, getBindColumn(column));
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getColumnWidth(column), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getRowHeight(row), MeasureSpec.EXACTLY));
        refreshItemViewHolder(viewHolder);
        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindViewHolder(viewHolder, row, getBindColumn(column));
        }


    } else if (itemType == ViewHolderType.ROW_HEADER) {
        mHeaderRowViewHolders.put(row, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderRowViewHolder(viewHolder, row);
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getHeaderRowWidth(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getRowHeight(row), MeasureSpec.EXACTLY));

        refreshHeaderRowViewHolder(viewHolder);
        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderRowViewHolder(viewHolder, row);
        }

    } else if (itemType == ViewHolderType.COLUMN_HEADER) {
        mHeaderColumnViewHolders.put(column, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderColumnViewHolder(viewHolder, getBindColumn(column));
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getColumnWidth(column), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getHeaderColumnHeight(), MeasureSpec.EXACTLY));

        refreshHeaderColumnViewHolder(viewHolder);

        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderColumnViewHolder(viewHolder, getBindColumn(column));
        }
    }
}
 
Example 16
Project: mvvm-template   File: AutoLinearLayout.java   View Source Code Vote up 5 votes
/**
 * Arranges the children in rows. Takes care about child margin, padding, gravity and
 * child layout gravity. Analog to vertical.
 *
 * @param left
 *         parent left
 * @param top
 *         parent top
 * @param right
 *         parent right
 * @param bottom
 *         parent bottom
 */
private void layoutHorizontal(int left, int top, int right, int bottom) {
    final int count = getChildCount();
    if (count == 0)
        return;

    final int width = right - getPaddingLeft() - left - getPaddingRight();
    final int height = bottom - getPaddingTop() - top - getPaddingBottom();

    int childTop = getPaddingTop();
    int childLeft = getPaddingLeft();

    int totalHorizontal = 0;
    int totalVertical = getPaddingTop() + getPaddingBottom();
    int row = 0;
    int maxChildHeight = 0;
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);

        if (child != null && child.getVisibility() != View.GONE) {
            if (child.getMeasuredHeight() == 0 || child.getMeasuredWidth() == 0)
                child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST),
                        MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));

            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();

            if (childLeft + childWidth + lp.leftMargin + lp.rightMargin > width + getPaddingLeft()) {
                updateChildPositionHorizontal(width, totalHorizontal, row, maxChildHeight);
                childLeft = getPaddingLeft();
                childTop += maxChildHeight;
                maxChildHeight = 0;
                row++;
                totalHorizontal = 0;
            }

            childLeft += lp.leftMargin;
            mListPositions.add(new ViewPosition(childLeft, childTop, row));

            int currentHeight = childHeight + lp.topMargin + lp.bottomMargin;
            if (maxChildHeight < currentHeight)
                maxChildHeight = currentHeight;

            childLeft += childWidth + lp.rightMargin;
            totalHorizontal += childWidth + lp.rightMargin + lp.leftMargin;
        }
    }

    updateChildPositionHorizontal(width, totalHorizontal, row, maxChildHeight);
    totalVertical += childTop + maxChildHeight;
    updateChildPositionVertical(height, totalVertical, row, 0);
    //mListPositions.clear();
}
 
Example 17
Project: chalkboard   File: EditDay.java   View Source Code Vote up 5 votes
private void setListViewHeightBasedOnChildren() {

        if (listAdapter == null)
            return;

        int totalHeight = 0;

        for (int i = 0; i < listAdapter.getCount(); i++) {

            final View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();

        }

        final ViewGroup.LayoutParams listViewLayoutParams = listView.getLayoutParams();
        listViewLayoutParams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(listViewLayoutParams);

    }
 
Example 18
Project: RotateRingView   File: CircleMenuLayout.java   View Source Code Vote up 5 votes
/**
 * 设置布局的宽高,并测量menu item宽高
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int resWidth = 0;
    int resHeight = 0;
    /**
     * 根据传入的参数,分别获取测量模式和测量值
     */
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);

    int height = MeasureSpec.getSize(heightMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);

    /**
     * 如果宽或者高的测量模式非精确值
     */
    if (widthMode != MeasureSpec.EXACTLY || heightMode != MeasureSpec.EXACTLY) {
        // 主要设置为背景图的高度
        resWidth = getSuggestedMinimumWidth();
        // 如果未设置背景图片,则设置为屏幕宽高的默认值
        resWidth = resWidth == 0 ? getDefaultWidth() : resWidth;
        resHeight = getSuggestedMinimumHeight();
        // 如果未设置背景图片,则设置为屏幕宽高的默认值
        resHeight = resHeight == 0 ? getDefaultWidth() : resHeight;
    } else {
        // 如果都设置为精确值,则直接取小值;
        resWidth = resHeight = Math.min(width, height);
    }
    setMeasuredDimension(resWidth, resHeight);
    // 获得半径
    mRadius = Math.max(getMeasuredWidth(), getMeasuredHeight());
    // menu item数量
    final int count = getChildCount();
    // menu item尺寸
    int childSize = (int) (mRadius * RADIO_DEFAULT_CHILD_DIMENSION);
    // menu item测量模式
    int childMode = MeasureSpec.EXACTLY;
    final float tmp = mRadius / 2f - childSize / 2f;
    // 迭代测量
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }
        // 计算menu item的尺寸;以及和设置好的模式,去对item进行测量
        int makeMeasureSpec = -1;
        if (child.getId() == R.id.id_circle_menu_item_center) {
            makeMeasureSpec = MeasureSpec.makeMeasureSpec(
                    (int) (tmp * 2.2f),
                    childMode);
        } else {
            makeMeasureSpec = MeasureSpec.makeMeasureSpec(childSize, childMode);
        }
        child.measure(makeMeasureSpec, makeMeasureSpec);
    }
}
 
Example 19
Project: airgram   File: ChannelCreateActivity.java   View Source Code Vote up 5 votes
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
    try {
        LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        View textView = lf.inflate(R.layout.group_create_bubble, null);
        TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
        String name = UserObject.getUserName(user);
        if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
            name = PhoneFormat.getInstance().format("+" + user.phone);
        }
        text.setText(name + ", ");

        int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        textView.measure(spec, spec);
        textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
        Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(b);
        canvas.translate(-textView.getScrollX(), -textView.getScrollY());
        textView.draw(canvas);
        textView.setDrawingCacheEnabled(true);
        Bitmap cacheBmp = textView.getDrawingCache();
        Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
        textView.destroyDrawingCache();

        final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
        bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

        SpannableStringBuilder ssb = new SpannableStringBuilder("");
        ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
        allSpans.add(span);
        selectedContacts.put(user.id, span);
        for (ImageSpan sp : allSpans) {
            ssb.append("<<");
            ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        nameTextView.setText(ssb);
        nameTextView.setSelection(ssb.length());
        return span;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return null;
}
 
Example 20
Project: SmoothRefreshLayout   File: HorizontalSmoothRefreshLayout.java   View Source Code Vote up 5 votes
@Override
protected void measureFooter(View child, LayoutParams lp, int widthMeasureSpec, int heightMeasureSpec) {
    if (isDisabledLoadMore() || isEnabledHideFooterView())
        return;
    int height = mFooterView.getCustomHeight();
    if (mFooterView.getStyle() == IRefreshView.STYLE_DEFAULT
            || mFooterView.getStyle() == IRefreshView.STYLE_PIN
            || mFooterView.getStyle() == IRefreshView.STYLE_FOLLOW_CENTER
            || mFooterView.getStyle() == IRefreshView.STYLE_FOLLOW_PIN) {
        if (height <= 0) {
            if (height == LayoutParams.MATCH_PARENT) lp.width = LayoutParams.MATCH_PARENT;
        } else lp.width = height;
        measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
        mIndicator.setFooterHeight(child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
    } else {
        if (height <= 0 && height != LayoutParams.MATCH_PARENT) {
            throw new IllegalArgumentException("If footer view type is " +
                    "STYLE_SCALE or STYLE_FOLLOW_SCALE, you must set a accurate height");
        } else {
            if (height == LayoutParams.MATCH_PARENT) {
                int specSize = MeasureSpec.getSize(heightMeasureSpec);
                height = Math.max(0, specSize - (getPaddingLeft() + getPaddingRight()
                        + lp.leftMargin + lp.rightMargin));
                mIndicator.setFooterHeight(height);
            } else {
                mIndicator.setFooterHeight(height + lp.leftMargin + lp.rightMargin);
            }
        }
        if (mFooterView.getStyle() == IRefreshView.STYLE_FOLLOW_SCALE) {
            if (mIndicator.getCurrentPos() <= mIndicator.getFooterHeight()) {
                lp.width = height;
                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
                return;
            }
        }
        final int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                getPaddingTop() + getPaddingBottom() + lp.topMargin + lp.bottomMargin, lp.height);
        final int childWidthMeasureSpec;
        if (isMovingFooter()) {
            final int maxWidth = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft()
                    - getPaddingRight() - lp.leftMargin - lp.rightMargin;
            int realWidth = Math.min(mIndicator.getCurrentPos() - lp.topMargin - lp
                    .rightMargin, maxWidth);
            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(realWidth > 0 ? realWidth : 0,
                    MeasureSpec.EXACTLY);
        } else {
            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY);
        }
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }
}