Example usage for android.view View getMeasuredWidth

List of usage examples for android.view View getMeasuredWidth

Introduction

In this page you can find the example usage for android.view View getMeasuredWidth.

Prototype

public final int getMeasuredWidth() 

Source Link

Document

Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).

Usage

From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java

public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId,
        Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description,
        final TextView breadcrumb) {
    // Pull out the root layout of the dialog and set the background drawable, to be
    // faded in during the transition.
    final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0);
    twoPane.setVisibility(View.INVISIBLE);

    // If the appropriate data is embedded in the intent and there is an icon specified
    // in the content fragment, we animate the icon from its initial position to the final
    // position. Otherwise, we perform a simpler transition in which the ActionFragment
    // slides in and the ContentFragment text fields slide in.
    mIntroAnimationInProgress = true;/*from   w ww.j a va  2  s. co m*/
    List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent());
    TransitionImageAnimation ltransitionAnimation = null;
    final Uri iconUri;
    final int color;
    if (images != null && images.size() > 0) {
        if (iconResourceId != 0) {
            iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId));
        } else if (iconResourceUri != null) {
            iconUri = iconResourceUri;
        } else {
            iconUri = null;
        }
        TransitionImage src = images.get(0);
        color = src.getBackground();
        if (iconUri != null) {
            ltransitionAnimation = new TransitionImageAnimation(contentView);
            ltransitionAnimation.addTransitionSource(src);
            ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0)
                    .interpolator(new DecelerateInterpolator(1f));
        }
    } else {
        iconUri = null;
        color = 0;
    }
    final TransitionImageAnimation transitionAnimation = ltransitionAnimation;

    // Fade out the old activity, and hard cut the new activity.
    activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out);

    int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background);
    mBgDrawable.setColor(bgColor);
    mBgDrawable.setAlpha(0);
    twoPane.setBackground(mBgDrawable);

    // If we're animating the icon, we create a new ImageView in which to place the embedded
    // bitmap. We place it in the root layout to match its location in the previous activity.
    mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout);
    if (transitionAnimation != null) {
        transitionAnimation.listener(new TransitionImageAnimation.Listener() {
            @Override
            public void onRemovedView(TransitionImage src, TransitionImage dst) {
                if (icon != null) {
                    //want to make sure that users still see at least the source image
                    // if the dst image is too large to finish downloading before the
                    // animation is done. Check if the icon is not visible. This mean
                    // BaseContentFragement have not finish downloading the image yet.
                    if (icon.getVisibility() != View.VISIBLE) {
                        icon.setImageDrawable(src.getBitmap());
                        int intrinsicWidth = icon.getDrawable().getIntrinsicWidth();
                        LayoutParams lp = icon.getLayoutParams();
                        lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth;
                        icon.setVisibility(View.VISIBLE);
                    }
                    icon.setAlpha(1f);
                }
                if (mShadowLayer != null) {
                    mShadowLayer.setShadowsAlpha(1f);
                }
                onIntroAnimationFinished();
            }
        });
        icon.setAlpha(0f);
        if (mShadowLayer != null) {
            mShadowLayer.setShadowsAlpha(0f);
        }
    }

    // We need to defer the remainder of the animation preparation until the first
    // layout has occurred, as we don't yet know the final location of the icon.
    twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time,  the texture is actually not created
            // delay a little so we can make sure all hardware layer is created before
            // animation, in that way we can avoid the jittering of start animation
            twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY);
        }

        final Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!mFragment.isAdded()) {
                    // We have been detached before this could run, so just bail
                    return;
                }

                twoPane.setVisibility(View.VISIBLE);
                final int secondaryDelay = SLIDE_IN_DISTANCE;

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255);
                oa.setDuration(ANIMATE_IN_DURATION);
                oa.setStartDelay(secondaryDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                View actionFragmentView = activity.findViewById(mActionAreaId);
                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
                int endDist = isRtl ? -actionFragmentView.getMeasuredWidth()
                        : actionFragmentView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                if (icon != null && transitionAnimation != null) {
                    // now we get the icon view in place,  update the transition target
                    TransitionImage target = new TransitionImage();
                    target.setUri(iconUri);
                    target.createFromImageView(icon);
                    if (icon.getBackground() instanceof ColorDrawable) {
                        ColorDrawable d = (ColorDrawable) icon.getBackground();
                        target.setBackground(d.getColor());
                    }
                    transitionAnimation.addTransitionTarget(target);
                    transitionAnimation.startTransition();
                } else if (icon != null) {
                    prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                            new DecelerateInterpolator(1.0f), true /* is the icon */);
                    if (mShadowLayer != null) {
                        mShadowLayer.setShadowsAlpha(0f);
                    }
                }
            }
        };
    });
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java

/**
 * ???.// w  ww  .  j av a 2 s.c o  m
 *
 * @param index the index
 */
public void computeTabImg(int index) {

    for (int i = 0; i < tabItemList.size(); i++) {
        TextView tv = tabItemList.get(i);
        tv.setTextColor(tabColor);
        tv.setSelected(false);
        if (index == i) {
            tv.setTextColor(tabSelectColor);
            tv.setSelected(true);
        }
    }

    //
    final View tabView = mTabLayout.getChildAt(index);
    AbViewUtil.measureView(tabView);

    LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight);
    mParams.topMargin = -tabSlidingHeight;
    mTabImg.setLayoutParams(mParams);

    AbLogUtil.d(AbSlidingSmoothTabView.class, "old--startX:" + startX);
    //????????tab
    AbLogUtil.d(AbSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "scrollX:" + scrollX);
    AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView right:" + tabView.getRight());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft());

    if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) {
        AbLogUtil.d(AbSlidingSmoothTabView.class, "??");
        int offsetX = 0;
        //??
        if (index == mTabLayout.getChildCount() - 1) {
            offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0);
            startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth();
        } else {
            offsetX = tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) {
        AbLogUtil.d(AbSlidingSmoothTabView.class, "?");
        //?  offsetX
        int offsetX = 0;
        if (index == 0) {
            offsetX = -scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            imageSlide(mTabImg, startX, 0, 0, 0);
            startX = 0;
        } else {
            offsetX = -tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else {
        int toX = tabView.getLeft() - scrollX;
        imageSlide(mTabImg, startX, toX, 0, 0);
        startX = toX;
    }

    mSelectedTabIndex = index;
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * ???.//www .j a  v a  2s.  c  o  m
 *
 * @param index the index
 */
public void computeTabImg(int index) {

    for (int i = 0; i < tabItemList.size(); i++) {
        TextView tv = tabItemList.get(i);
        tv.setTextColor(tabColor);
        tv.setSelected(false);
        if (index == i) {
            tv.setTextColor(tabSelectColor);
            tv.setSelected(true);
        }
    }

    //
    final View tabView = mTabLayout.getChildAt(index);
    ESViewUtil.measureView(tabView);

    LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight);
    mParams.topMargin = -tabSlidingHeight;
    mTabImg.setLayoutParams(mParams);

    ESLogUtil.d(ESSlidingSmoothTabView.class, "old--startX:" + startX);
    //????????tab
    ESLogUtil.d(ESSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "scrollX:" + scrollX);
    ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView right:" + tabView.getRight());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft());

    if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) {
        ESLogUtil.d(ESSlidingSmoothTabView.class, "??");
        int offsetX = 0;
        //??
        if (index == mTabLayout.getChildCount() - 1) {
            offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0);
            startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth();
        } else {
            offsetX = tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) {
        ESLogUtil.d(ESSlidingSmoothTabView.class, "?");
        //?  offsetX
        int offsetX = 0;
        if (index == 0) {
            offsetX = -scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            imageSlide(mTabImg, startX, 0, 0, 0);
            startX = 0;
        } else {
            offsetX = -tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else {
        int toX = tabView.getLeft() - scrollX;
        imageSlide(mTabImg, startX, toX, 0, 0);
        startX = toX;
    }

    mSelectedTabIndex = index;
}

From source file:com.astuetz.viewpager.extensions.SwipeyTabsView.java

/**
 * {@inheritDoc}//from w w  w.ja va2  s  . co m
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int maxTabHeight = 0;

    mWidthMeasureSpec = widthMeasureSpec;
    mHeightMeasureSpec = heightMeasureSpec;

    final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec),
            MeasureSpec.AT_MOST);
    final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec),
            MeasureSpec.AT_MOST);

    for (int i = 0; i < mTabsCount; i++) {
        final View child = getChildAt(i);

        if (child.getVisibility() == GONE)
            continue;

        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);

        mPositions.get(i).width = child.getMeasuredWidth();
        mPositions.get(i).height = child.getMeasuredHeight();

        maxTabHeight = Math.max(maxTabHeight, mPositions.get(i).height);
    }

    setMeasuredDimension(resolveSize(0, widthMeasureSpec),
            resolveSize(maxTabHeight + getPaddingTop() + getPaddingBottom(), heightMeasureSpec));

}

From source file:com.actionbarsherlock.internal.widget.IcsSpinner.java

/**
 * Creates and positions all views for this Spinner.
 *
 * @param delta Change in the selected position. +1 moves selection is moving to the right,
 * so views are scrolling to the left. -1 means selection is moving to the left.
 *///  ww  w .ja  v  a 2  s  .  com
@Override
void layout(int delta, boolean animate) {
    int childrenLeft = mSpinnerPadding.left;
    int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right;

    if (mDataChanged) {
        handleDataChanged();
    }

    // Handle the empty set by removing all views
    if (mItemCount == 0) {
        resetList();
        return;
    }

    if (mNextSelectedPosition >= 0) {
        setSelectedPositionInt(mNextSelectedPosition);
    }

    recycleAllViews();

    // Clear out old views
    removeAllViewsInLayout();

    // Make selected view and position it
    mFirstPosition = mSelectedPosition;
    View sel = makeAndAddView(mSelectedPosition);
    int width = sel.getMeasuredWidth();
    int selectedOffset = childrenLeft;
    switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2);
        break;
    case Gravity.RIGHT:
        selectedOffset = childrenLeft + childrenWidth - width;
        break;
    }
    sel.offsetLeftAndRight(selectedOffset);

    // Flush any cached views that did not get reused above
    mRecycler.clear();

    invalidate();

    checkSelectionChanged();

    mDataChanged = false;
    mNeedSync = false;
    setNextSelectedPositionInt(mSelectedPosition);
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

public void scrollToColumn(int column, boolean animate) {
    if (mLists.size() <= column) {
        return;/*  ww  w  .  j  a  v a  2  s.  co m*/
    }

    View parent = (View) mLists.get(column).getParent();
    int newX = parent.getLeft() - (getMeasuredWidth() - parent.getMeasuredWidth()) / 2;
    int maxScroll = mRootLayout.getMeasuredWidth() - getMeasuredWidth();
    newX = newX < 0 ? 0 : newX;
    newX = newX > maxScroll ? maxScroll : newX;
    if (getScrollX() != newX) {
        mScroller.forceFinished(true);
        if (animate) {
            mScroller.startScroll(getScrollX(), getScrollY(), newX - getScrollX(), 0,
                    SCROLL_ANIMATION_DURATION);
            ViewCompat.postInvalidateOnAnimation(this);
        } else {
            scrollTo(newX, getScrollY());
        }
    }
}

From source file:com.asc_ii.bangnote.bigbang.BigBangLayout.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int widthSize = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();
    int contentWidthSize = widthSize - mActionBar.getContentPadding();
    int heightSize = 0;

    int childCount = getChildCount();

    int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    mLines = new ArrayList<>();
    Line currentLine = null;/*  www  .  j a va  2 s  .  com*/
    int currentLineWidth = contentWidthSize;
    for (int i = 0; i < childCount; i++) {

        View child = getChildAt(i);

        if (mActionBar == child) {
            continue;
        }

        child.measure(measureSpec, measureSpec);

        if (currentLineWidth > 0) {
            currentLineWidth += mItemSpace;
        }
        currentLineWidth += child.getMeasuredWidth();
        if (mLines.size() == 0 || currentLineWidth > contentWidthSize) {
            heightSize += child.getMeasuredHeight();
            currentLineWidth = child.getMeasuredWidth();
            currentLine = new Line(mLines.size());
            mLines.add(currentLine);
        }
        Item item = new Item(currentLine);
        item.view = child;
        item.index = i;
        item.width = child.getMeasuredWidth();
        item.height = child.getMeasuredHeight();
        currentLine.addItem(item);
    }

    Line firstSelectedLine = findFirstSelectedLine();
    Line lastSelectedLine = findLastSelectedLine();
    if (firstSelectedLine != null && lastSelectedLine != null) {
        int selectedLineHeight = (lastSelectedLine.index - firstSelectedLine.index + 1)
                * (firstSelectedLine.getHeight() + mLineSpace);
        mActionBar.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(selectedLineHeight, MeasureSpec.UNSPECIFIED));
    }

    int size = heightSize + getPaddingTop() + getPaddingBottom() + (mLines.size() - 1) * mLineSpace
            + mActionBarTopHeight + mActionBarBottomHeight;
    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY));
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabIndicatorView.java

private void updateIndicator(View anchorView) {
    if (anchorView != null) {
        updateIndicator(anchorView.getLeft(), anchorView.getMeasuredWidth());
        ((Checkable) anchorView).setChecked(true);
    } else {/*from w w w  .j  ava  2  s.c om*/
        updateIndicator(getWidth(), 0);
    }
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@WorkerThread
private void showPopupAt(final LineNumber lineNumber, final String msg) {
    mHandler.post(new Runnable() {
        @Override/*from   w w  w .ja v  a2  s.  c  o  m*/
        public void run() {
            if (isFinishing())
                return;
            //get relative position of expression at edittext
            Point position = mCodeView.getDebugPosition(lineNumber.getLine(), lineNumber.getColumn(),
                    Gravity.TOP);
            DLog.d(TAG, "generate: " + position);
            dismissPopup();
            //create new popup
            PopupWindow window = new PopupWindow(DebugActivity.this);
            LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View container = inflater.inflate(R.layout.popup_expr_result, null);
            container.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            int windowHeight = container.getMeasuredHeight();
            int windowWidth = container.getMeasuredWidth();

            window.setContentView(container);
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.setTouchable(true);
            window.setSplitTouchEnabled(true);
            window.setOutsideTouchable(true);

            window.showAtLocation(mCodeView, Gravity.NO_GRAVITY, position.x - windowWidth / 3,
                    position.y + toolbar.getHeight() - windowHeight);

            TextView txtResult = container.findViewById(R.id.txt_result);
            txtResult.setText(msg);
            AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f);
            alphaAnimation.setDuration(1000);
            alphaAnimation.setRepeatMode(Animation.REVERSE);
            alphaAnimation.setRepeatCount(Animation.INFINITE);
            txtResult.startAnimation(alphaAnimation);
            DebugActivity.this.mPopupWindow = window;
        }
    });
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerViewPager.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    //populate();
    // Use reflection
    callPopulate();//from ww  w.ja v  a2 s  .c o m

    // Everything below is mostly copied from FrameLayout.
    int count = getChildCount();

    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY
            || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;

    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
            maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
            childState = combineMeasuredStates(childState, child.getMeasuredState());
            if (measureMatchParentChildren) {
                if (lp.width == LayoutParams.MATCH_PARENT || lp.height == LayoutParams.MATCH_PARENT) {
                    mMatchParentChildren.add(child);
                }
            }
        }
    }

    // Account for padding too
    maxWidth += getPaddingLeft() + getPaddingRight();
    maxHeight += getPaddingTop() + getPaddingBottom();

    // Check against our minimum height and width
    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

    // Check against our foreground's minimum height and width
    if (SUtils.isApi_23_OrHigher()) {
        final Drawable drawable = getForeground();
        if (drawable != null) {
            maxHeight = Math.max(maxHeight, drawable.getMinimumHeight());
            maxWidth = Math.max(maxWidth, drawable.getMinimumWidth());
        }
    }

    setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
            resolveSizeAndState(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT));

    count = mMatchParentChildren.size();
    if (count > 1) {
        for (int i = 0; i < count; i++) {
            final View child = mMatchParentChildren.get(i);

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final int childWidthMeasureSpec;
            final int childHeightMeasureSpec;

            if (lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
            } else {
                childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
                        getPaddingLeft() + getPaddingRight(), lp.width);
            }

            if (lp.height == LayoutParams.MATCH_PARENT) {
                childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
            } else {
                childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                        getPaddingTop() + getPaddingBottom(), lp.height);
            }

            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }

    mMatchParentChildren.clear();
}