List of usage examples for android.view View getMeasuredHeight
public final int getMeasuredHeight()
From source file:com.appunite.list.ListView.java
/** * Re-measure a child, and if its width changes, lay it out preserving its * top, and adjust the children below it appropriately. * @param child The child// w w w. ja v a2 s .c o m * @param childIndex The view group index of the child. * @param numChildren The number of children in the view group. */ private void measureAndAdjustDown(View child, int childIndex, int numChildren) { int oldHeight = child.getHeight(); measureItem(child); if (child.getMeasuredHeight() != oldHeight) { // lay out the view, preserving its top relayoutMeasuredItem(child); // adjust views below appropriately final int heightDelta = child.getMeasuredHeight() - oldHeight; for (int i = childIndex + 1; i < numChildren; i++) { getChildAt(i).offsetTopAndBottom(heightDelta); } } }
From source file:android.support.designox.widget.CoordinatorLayout.java
/** * Lay out a child view with no special handling. This will position the child as * if it were within a FrameLayout or similar simple frame. * * @param child child view to lay out//from w w w. j a v a 2 s . c o m * @param layoutDirection ViewCompat constant for the desired layout direction */ private void layoutChild(View child, int layoutDirection) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final Rect parent = mTempRect1; parent.set(getPaddingLeft() + lp.leftMargin, getPaddingTop() + lp.topMargin, getWidth() - getPaddingRight() - lp.rightMargin, getHeight() - getPaddingBottom() - lp.bottomMargin); if (mLastInsets != null && ViewCompat.getFitsSystemWindows(this) && !ViewCompat.getFitsSystemWindows(child)) { // If we're set to handle insets but this child isn't, then it has been measured as // if there are no insets. We need to lay it out to match. parent.left += mLastInsets.getSystemWindowInsetLeft(); parent.top += mLastInsets.getSystemWindowInsetTop(); parent.right -= mLastInsets.getSystemWindowInsetRight(); parent.bottom -= mLastInsets.getSystemWindowInsetBottom(); } final Rect out = mTempRect2; GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), parent, out, layoutDirection); child.layout(out.left, out.top, out.right, out.bottom); }
From source file:com.appunite.list.ListView.java
/** * Put mSelectedPosition in the middle of the screen and then build up and * down from there. This method forces mSelectedPosition to the center. * * @param childrenTop Top of the area in which children can be drawn, as * measured in pixels/* w w w . ja va 2s .co m*/ * @param childrenBottom Bottom of the area in which children can be drawn, * as measured in pixels * @return Currently selected view */ private View fillFromMiddle(int childrenTop, int childrenBottom) { int height = childrenBottom - childrenTop; int position = reconcileSelectedPosition(); View sel = makeAndAddView(position, childrenTop, true, mListPadding.left, true); mFirstPosition = position; int selHeight = sel.getMeasuredHeight(); if (selHeight <= height) { sel.offsetTopAndBottom((height - selHeight) / 2); } fillAboveAndBelow(sel, position); if (!mStackFromBottom) { correctTooHigh(getChildCount()); } else { correctTooLow(getChildCount()); } return sel; }
From source file:com.cxsplay.wallyskim.widget.flexbox.FlexboxLayout.java
/** * Sub method for {@link #onLayout(boolean, int, int, int, int)} when the * {@link #mFlexDirection} is either {@link #FLEX_DIRECTION_COLUMN} or * {@link #FLEX_DIRECTION_COLUMN_REVERSE}. * * @param isRtl {@code true} if the horizontal layout direction is right to left, * {@code false}// w w w . jav a2s. co m * otherwise * @param fromBottomToTop {@code true} if the layout direction is bottom to top, {@code false} * otherwise * @param left the left position of this View * @param top the top position of this View * @param right the right position of this View * @param bottom the bottom position of this View * @see #getFlexWrap() * @see #setFlexWrap(int) * @see #getJustifyContent() * @see #setJustifyContent(int) * @see #getAlignItems() * @see #setAlignItems(int) * @see LayoutParams#alignSelf */ private void layoutVertical(boolean isRtl, boolean fromBottomToTop, int left, int top, int right, int bottom) { int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); int paddingRight = getPaddingRight(); int childLeft = getPaddingLeft(); int currentViewIndex = 0; int width = right - left; int height = bottom - top; // childRight is used if the mFlexWrap is FLEX_WRAP_WRAP_REVERSE otherwise // childLeft is used to align the horizontal position of the children views. int childRight = width - paddingRight; // Use float to reduce the round error that may happen in when justifyContent == // SPACE_BETWEEN or SPACE_AROUND float childTop; // Used only for if the direction is from bottom to top float childBottom; for (int i = 0, size = mFlexLines.size(); i < size; i++) { FlexLine flexLine = mFlexLines.get(i); if (hasDividerBeforeFlexLine(i)) { childLeft += mDividerVerticalWidth; childRight -= mDividerVerticalWidth; } float spaceBetweenItem = 0f; switch (mJustifyContent) { case JUSTIFY_CONTENT_FLEX_START: childTop = paddingTop; childBottom = height - paddingBottom; break; case JUSTIFY_CONTENT_FLEX_END: childTop = height - flexLine.mMainSize + paddingBottom; childBottom = flexLine.mMainSize - paddingTop; break; case JUSTIFY_CONTENT_CENTER: childTop = paddingTop + (height - flexLine.mMainSize) / 2f; childBottom = height - paddingBottom - (height - flexLine.mMainSize) / 2f; break; case JUSTIFY_CONTENT_SPACE_AROUND: int visibleCount = flexLine.getItemCountNotGone(); if (visibleCount != 0) { spaceBetweenItem = (height - flexLine.mMainSize) / (float) visibleCount; } childTop = paddingTop + spaceBetweenItem / 2f; childBottom = height - paddingBottom - spaceBetweenItem / 2f; break; case JUSTIFY_CONTENT_SPACE_BETWEEN: childTop = paddingTop; int visibleItem = flexLine.getItemCountNotGone(); float denominator = visibleItem != 1 ? visibleItem - 1 : 1f; spaceBetweenItem = (height - flexLine.mMainSize) / denominator; childBottom = height - paddingBottom; break; default: throw new IllegalStateException("Invalid justifyContent is set: " + mJustifyContent); } spaceBetweenItem = Math.max(spaceBetweenItem, 0); for (int j = 0; j < flexLine.mItemCount; j++) { View child = getReorderedChildAt(currentViewIndex); if (child == null) { continue; } else if (child.getVisibility() == View.GONE) { currentViewIndex++; continue; } LayoutParams lp = ((LayoutParams) child.getLayoutParams()); childTop += lp.topMargin; childBottom -= lp.bottomMargin; if (hasDividerBeforeChildAtAlongMainAxis(currentViewIndex, j)) { childTop += mDividerHorizontalHeight; childBottom -= mDividerHorizontalHeight; } if (isRtl) { if (fromBottomToTop) { layoutSingleChildVertical(child, flexLine, true, mAlignItems, childRight - child.getMeasuredWidth(), Math.round(childBottom) - child.getMeasuredHeight(), childRight, Math.round(childBottom)); } else { layoutSingleChildVertical(child, flexLine, true, mAlignItems, childRight - child.getMeasuredWidth(), Math.round(childTop), childRight, Math.round(childTop) + child.getMeasuredHeight()); } } else { if (fromBottomToTop) { layoutSingleChildVertical(child, flexLine, false, mAlignItems, childLeft, Math.round(childBottom) - child.getMeasuredHeight(), childLeft + child.getMeasuredWidth(), Math.round(childBottom)); } else { layoutSingleChildVertical(child, flexLine, false, mAlignItems, childLeft, Math.round(childTop), childLeft + child.getMeasuredWidth(), Math.round(childTop) + child.getMeasuredHeight()); } } childTop += child.getMeasuredHeight() + spaceBetweenItem + lp.bottomMargin; childBottom -= child.getMeasuredHeight() + spaceBetweenItem + lp.topMargin; currentViewIndex++; flexLine.mLeft = Math.min(flexLine.mLeft, child.getLeft() - lp.leftMargin); flexLine.mTop = Math.min(flexLine.mTop, child.getTop() - lp.topMargin); flexLine.mRight = Math.max(flexLine.mRight, child.getRight() + lp.rightMargin); flexLine.mBottom = Math.max(flexLine.mBottom, child.getBottom() + lp.bottomMargin); } childLeft += flexLine.mCrossSize; childRight -= flexLine.mCrossSize; } }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // For simple implementation, or internal size is always 0. // We depend on the container to specify the layout size of // our view. We can't really know what it is since we will be // adding and removing different arbitrary views and do not // want the layout to change as this happens. setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec)); // Children are just made to fill our space. int childWidthSize = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); int childHeightSize = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); /*/*w w w . jav a 2 s . co m*/ * Make sure all children have been properly measured. Decor views first. * Right now we cheat and make this less complicated by assuming decor * views won't intersect. We will pin to edges based on gravity. */ int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp != null && lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; Log.d(TAG, "gravity: " + lp.gravity + " hgrav: " + hgrav + " vgrav: " + vgrav); int widthMode = MeasureSpec.AT_MOST; int heightMode = MeasureSpec.AT_MOST; boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM; boolean consumeHorizontal = hgrav == Gravity.LEFT || hgrav == Gravity.RIGHT; if (consumeVertical) { widthMode = MeasureSpec.EXACTLY; } else if (consumeHorizontal) { heightMode = MeasureSpec.EXACTLY; } /* end of if */ final int widthSpec = MeasureSpec.makeMeasureSpec(childWidthSize, widthMode); final int heightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, heightMode); child.measure(widthSpec, heightSpec); if (consumeVertical) { childHeightSize -= child.getMeasuredHeight(); } else if (consumeHorizontal) { childWidthSize -= child.getMeasuredWidth(); } /* end of if */ } /* end of if */ } /* end of if */ } /* end of for */ mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY); mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY); // Make sure we have created all fragments that we need to have shown. mInLayout = true; populate(); mInLayout = false; // Page views next. size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { if (DEBUG) Log.v(TAG, "Measuring #" + i + " " + child + ": " + mChildWidthMeasureSpec); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null || !lp.isDecor) { child.measure(mChildWidthMeasureSpec, mChildHeightMeasureSpec); } /* end of if */ } /* end of if */ } /* end of for */ }
From source file:com.cxsplay.wallyskim.widget.flexbox.FlexboxLayout.java
/** * Sub method for {@link #onLayout(boolean, int, int, int, int)} when the * {@link #mFlexDirection} is either {@link #FLEX_DIRECTION_ROW} or * {@link #FLEX_DIRECTION_ROW_REVERSE}.// ww w.j a va2 s . c o m * * @param isRtl {@code true} if the horizontal layout direction is right to left, {@code * false} otherwise. * @param left the left position of this View * @param top the top position of this View * @param right the right position of this View * @param bottom the bottom position of this View * @see #getFlexWrap() * @see #setFlexWrap(int) * @see #getJustifyContent() * @see #setJustifyContent(int) * @see #getAlignItems() * @see #setAlignItems(int) * @see LayoutParams#alignSelf */ private void layoutHorizontal(boolean isRtl, int left, int top, int right, int bottom) { int paddingLeft = getPaddingLeft(); int paddingRight = getPaddingRight(); // Use float to reduce the round error that may happen in when justifyContent == // SPACE_BETWEEN or SPACE_AROUND float childLeft; int currentViewIndex = 0; int height = bottom - top; int width = right - left; // childBottom is used if the mFlexWrap is FLEX_WRAP_WRAP_REVERSE otherwise // childTop is used to align the vertical position of the children views. int childBottom = height - getPaddingBottom(); int childTop = getPaddingTop(); // Used only for RTL layout // Use float to reduce the round error that may happen in when justifyContent == // SPACE_BETWEEN or SPACE_AROUND float childRight; for (int i = 0, size = mFlexLines.size(); i < size; i++) { FlexLine flexLine = mFlexLines.get(i); if (hasDividerBeforeFlexLine(i)) { childBottom -= mDividerHorizontalHeight; childTop += mDividerHorizontalHeight; } float spaceBetweenItem = 0f; switch (mJustifyContent) { case JUSTIFY_CONTENT_FLEX_START: childLeft = paddingLeft; childRight = width - paddingRight; break; case JUSTIFY_CONTENT_FLEX_END: childLeft = width - flexLine.mMainSize + paddingRight; childRight = flexLine.mMainSize - paddingLeft; break; case JUSTIFY_CONTENT_CENTER: childLeft = paddingLeft + (width - flexLine.mMainSize) / 2f; childRight = width - paddingRight - (width - flexLine.mMainSize) / 2f; break; case JUSTIFY_CONTENT_SPACE_AROUND: int visibleCount = flexLine.getItemCountNotGone(); if (visibleCount != 0) { spaceBetweenItem = (width - flexLine.mMainSize) / (float) visibleCount; } childLeft = paddingLeft + spaceBetweenItem / 2f; childRight = width - paddingRight - spaceBetweenItem / 2f; break; case JUSTIFY_CONTENT_SPACE_BETWEEN: childLeft = paddingLeft; int visibleItem = flexLine.getItemCountNotGone(); float denominator = visibleItem != 1 ? visibleItem - 1 : 1f; spaceBetweenItem = (width - flexLine.mMainSize) / denominator; childRight = width - paddingRight; break; default: throw new IllegalStateException("Invalid justifyContent is set: " + mJustifyContent); } spaceBetweenItem = Math.max(spaceBetweenItem, 0); for (int j = 0; j < flexLine.mItemCount; j++) { View child = getReorderedChildAt(currentViewIndex); if (child == null) { continue; } else if (child.getVisibility() == View.GONE) { currentViewIndex++; continue; } LayoutParams lp = ((LayoutParams) child.getLayoutParams()); childLeft += lp.leftMargin; childRight -= lp.rightMargin; if (hasDividerBeforeChildAtAlongMainAxis(currentViewIndex, j)) { childLeft += mDividerVerticalWidth; childRight -= mDividerVerticalWidth; } if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) { if (isRtl) { layoutSingleChildHorizontal(child, flexLine, mFlexWrap, mAlignItems, Math.round(childRight) - child.getMeasuredWidth(), childBottom - child.getMeasuredHeight(), Math.round(childRight), childBottom); } else { layoutSingleChildHorizontal(child, flexLine, mFlexWrap, mAlignItems, Math.round(childLeft), childBottom - child.getMeasuredHeight(), Math.round(childLeft) + child.getMeasuredWidth(), childBottom); } } else { if (isRtl) { layoutSingleChildHorizontal(child, flexLine, mFlexWrap, mAlignItems, Math.round(childRight) - child.getMeasuredWidth(), childTop, Math.round(childRight), childTop + child.getMeasuredHeight()); } else { layoutSingleChildHorizontal(child, flexLine, mFlexWrap, mAlignItems, Math.round(childLeft), childTop, Math.round(childLeft) + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } childLeft += child.getMeasuredWidth() + spaceBetweenItem + lp.rightMargin; childRight -= child.getMeasuredWidth() + spaceBetweenItem + lp.leftMargin; currentViewIndex++; flexLine.mLeft = Math.min(flexLine.mLeft, child.getLeft() - lp.leftMargin); flexLine.mTop = Math.min(flexLine.mTop, child.getTop() - lp.topMargin); flexLine.mRight = Math.max(flexLine.mRight, child.getRight() + lp.rightMargin); flexLine.mBottom = Math.max(flexLine.mBottom, child.getBottom() + lp.bottomMargin); } childTop += flexLine.mCrossSize; childBottom -= flexLine.mCrossSize; } }
From source file:com.appunite.list.HorizontalListView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Sets up mListPadding super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int childWidth = 0; int childHeight = 0; int childState = 0; mItemCount = mAdapter == null ? 0 : mAdapter.getCount(); if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) { final View child = obtainView(0, mIsScrap); measureScrapChild(child, 0, heightMeasureSpec); childWidth = child.getMeasuredWidth(); childHeight = child.getMeasuredHeight(); childState = Compat.combineMeasuredStates(childState, Compat.getMeasuredState(child)); if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) { mRecycler.addScrapView(child, -1); }/*from w w w.j a v a2s . c om*/ } if (heightMode == MeasureSpec.UNSPECIFIED) { heightSize = mListPadding.top + mListPadding.bottom + childHeight + getHorizontalScrollbarHeight(); } else { heightSize |= (childState & MEASURED_STATE_MASK); } if (widthMode == MeasureSpec.UNSPECIFIED) { widthSize = mListPadding.left + mListPadding.right + childWidth + getHorizontalFadingEdgeLength() * 2; } if (widthMode == MeasureSpec.AT_MOST) { // TODO: after first layout we should maybe start at the first visible position, not 0 widthSize = measureWidthOfChildren(heightMeasureSpec, 0, NO_POSITION, widthSize, -1); } setMeasuredDimension(widthSize, heightSize); mHeightMeasureSpec = heightMeasureSpec; }
From source file:com.appunite.list.ListView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Sets up mListPadding super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int childWidth = 0; int childHeight = 0; int childState = 0; mItemCount = mAdapter == null ? 0 : mAdapter.getCount(); if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) { final View child = obtainView(0, mIsScrap); measureScrapChild(child, 0, widthMeasureSpec); childWidth = child.getMeasuredWidth(); childHeight = child.getMeasuredHeight(); childState = Compat.combineMeasuredStates(childState, Compat.getMeasuredState(child)); if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) { mRecycler.addScrapView(child, -1); }/*from ww w.j ava 2 s . c om*/ } if (widthMode == MeasureSpec.UNSPECIFIED) { widthSize = mListPadding.left + mListPadding.right + childWidth + getVerticalScrollbarWidth(); } else { widthSize |= (childState & MEASURED_STATE_MASK); } if (heightMode == MeasureSpec.UNSPECIFIED) { heightSize = mListPadding.top + mListPadding.bottom + childHeight + getVerticalFadingEdgeLength() * 2; } if (heightMode == MeasureSpec.AT_MOST) { // TODO: after first layout we should maybe start at the first visible position, not 0 heightSize = measureHeightOfChildren(widthMeasureSpec, 0, NO_POSITION, heightSize, -1); } setMeasuredDimension(widthSize, heightSize); mWidthMeasureSpec = widthMeasureSpec; }
From source file:com.awrtechnologies.carbudgetsales.hlistview.widget.HListView.java
@TargetApi(11) @Override/*from w w w. j a va2s .com*/ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Sets up mListPadding super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int childWidth = 0; int childHeight = 0; int childState = 0; mItemCount = mAdapter == null ? 0 : mAdapter.getCount(); if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) { if (LOG_ENABLED) { Log.d(LOG_TAG, "let's measure a scrap child"); } final View child = obtainView(0, mIsScrap); measureScrapChildWidth(child, 0, heightMeasureSpec); childWidth = child.getMeasuredWidth(); childHeight = child.getMeasuredHeight(); if (android.os.Build.VERSION.SDK_INT >= 11) { childState = combineMeasuredStates(childState, child.getMeasuredState()); } if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) { mRecycler.addScrapView(child, -1); } } if (heightMode == MeasureSpec.UNSPECIFIED) { heightSize = mListPadding.top + mListPadding.bottom + childHeight + getHorizontalScrollbarHeight(); } else if (heightMode == MeasureSpec.AT_MOST && mItemCount > 0 && mMeasureWithChild > -1) { // TODO: need a better way in case of "wrap_content" int[] result = measureWithLargeChildren(heightMeasureSpec, mMeasureWithChild, mMeasureWithChild, widthSize, heightSize, -1); heightSize = result[1]; } else { // match_parent, dimension if (android.os.Build.VERSION.SDK_INT >= 11) { heightSize |= (childState & MEASURED_STATE_MASK); } } if (widthMode == MeasureSpec.UNSPECIFIED) { widthSize = mListPadding.left + mListPadding.right + childWidth + getHorizontalFadingEdgeLength() * 2; } if (widthMode == MeasureSpec.AT_MOST) { widthSize = measureWidthOfChildren(heightMeasureSpec, 0, NO_POSITION, widthSize, -1); } if (LOG_ENABLED) { Log.d(LOG_TAG, "final size: " + widthSize + "x" + heightSize); } setMeasuredDimension(widthSize, heightSize); mHeightMeasureSpec = heightMeasureSpec; }
From source file:com.awrtechnologies.valor.valorfireplace.hlistview.widget.HListView.java
@TargetApi(11) @Override//from w w w . j ava 2 s.c om protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Sets up mListPadding super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); int childWidth = 0; int childHeight = 0; int childState = 0; mItemCount = mAdapter == null ? 0 : mAdapter.getCount(); if (mItemCount > 0 && (widthMode == View.MeasureSpec.UNSPECIFIED || heightMode == View.MeasureSpec.UNSPECIFIED)) { if (LOG_ENABLED) { Log.d(LOG_TAG, "let's measure a scrap child"); } final View child = obtainView(0, mIsScrap); measureScrapChildWidth(child, 0, heightMeasureSpec); childWidth = child.getMeasuredWidth(); childHeight = child.getMeasuredHeight(); if (android.os.Build.VERSION.SDK_INT >= 11) { childState = combineMeasuredStates(childState, child.getMeasuredState()); } if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) { mRecycler.addScrapView(child, -1); } } if (heightMode == View.MeasureSpec.UNSPECIFIED) { heightSize = mListPadding.top + mListPadding.bottom + childHeight + getHorizontalScrollbarHeight(); } else if (heightMode == View.MeasureSpec.AT_MOST && mItemCount > 0 && mMeasureWithChild > -1) { // TODO: need a better way in case of "wrap_content" int[] result = measureWithLargeChildren(heightMeasureSpec, mMeasureWithChild, mMeasureWithChild, widthSize, heightSize, -1); heightSize = result[1]; } else { // match_parent, dimension if (android.os.Build.VERSION.SDK_INT >= 11) { heightSize |= (childState & MEASURED_STATE_MASK); } } if (widthMode == View.MeasureSpec.UNSPECIFIED) { widthSize = mListPadding.left + mListPadding.right + childWidth + getHorizontalFadingEdgeLength() * 2; } if (widthMode == View.MeasureSpec.AT_MOST) { widthSize = measureWidthOfChildren(heightMeasureSpec, 0, NO_POSITION, widthSize, -1); } if (LOG_ENABLED) { Log.d(LOG_TAG, "final size: " + widthSize + "x" + heightSize); } setMeasuredDimension(widthSize, heightSize); mHeightMeasureSpec = heightMeasureSpec; }