private static boolean shouldHandleMeasuredWidthTooSmall(View view, PercentLayoutInfo info) { int state = view.getMeasuredWidthAndState() & View.MEASURED_STATE_MASK; return state == View.MEASURED_STATE_TOO_SMALL && info.widthPercent >= 0 && info.mPreservedParams.width == ViewGroup.LayoutParams.WRAP_CONTENT; }
@TargetApi(HONEYCOMB) public S hasMeasuredWidthAndState(int widthAndState) { isNotNull(); int actualWidthAndState = actual.getMeasuredWidthAndState(); assertThat(actualWidthAndState) // .overridingErrorMessage("Expected measured width and state <%s> but was <%s>", widthAndState, actualWidthAndState) // .isEqualTo(widthAndState); return myself; }
public static int getMeasuredWidthAndState(View view) { return view.getMeasuredWidthAndState(); }
@TargetApi(HONEYCOMB) public S hasMeasuredWidthAndState(int widthAndState) { isNotNull(); int actualWidthAndState = actual.getMeasuredWidthAndState(); assertThat(actualWidthAndState) // .overridingErrorMessage("Expected measured width and state <%s> but was <%s>", widthAndState, actualWidthAndState) // .isEqualTo(widthAndState); return myself; }
int contentViewHeight = 0; if (mContentView != null) { int contentViewWidth = mContentView.getMeasuredWidthAndState(); contentViewHeight = mContentView.getMeasuredHeightAndState(); LayoutParams lp = (LayoutParams) mContentView.getLayoutParams(); int menuViewWidth = leftMenu.getMeasuredWidthAndState(); int menuViewWidth = rightMenu.getMeasuredWidthAndState();
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int measuredWidth = getMeasuredWidth(); View tabsContainer = getChildAt(0); if (tabsContainer != null) { int measuredWidthAndState, measuredHeightAndState; ViewGroup.LayoutParams lp = tabsContainer.getLayoutParams(); if (lp.width == LayoutParams.MATCH_PARENT && measuredWidth - getPaddingLeft() - getPaddingRight() > tabsContainer.getMeasuredWidth()) {//tabsContainer宽度不够,让其充满SlidingTabLayout measuredWidthAndState = MeasureSpec.makeMeasureSpec(measuredWidth - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY); } else if (lp.width != LayoutParams.MATCH_PARENT && lp.width != LayoutParams.WRAP_CONTENT) {//tabsContainer指定了宽度值,使其生效 measuredWidthAndState = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); } else if (lp.height != LayoutParams.WRAP_CONTENT) {//高度不是自适应,说明需要重新测量高度,宽度不做调整 measuredWidthAndState = tabsContainer.getMeasuredWidthAndState(); } else { return; } if (lp.height == LayoutParams.MATCH_PARENT) {//tabsContainer指定最大高度,使其生效 measuredHeightAndState = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY); } else if (lp.height != LayoutParams.WRAP_CONTENT) {//tabsContainer指定高度值,使其生效 measuredHeightAndState = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY); } else { measuredHeightAndState = tabsContainer.getMeasuredHeightAndState(); } tabsContainer.measure(measuredWidthAndState, measuredHeightAndState); } }
int contentViewWidth = mContentView.getMeasuredWidthAndState(); int contentViewHeight = mContentView.getMeasuredHeightAndState(); LayoutParams lp = (LayoutParams) mContentView.getLayoutParams(); int menuViewWidth = mEndSwiper.getMenuView().getMeasuredWidthAndState(); int menuViewHeight = mEndSwiper.getMenuView().getMeasuredHeightAndState(); lp = (LayoutParams) mEndSwiper.getMenuView().getLayoutParams(); int menuViewWidth = mBeginSwiper.getMenuView().getMeasuredWidthAndState(); int menuViewHeight = mBeginSwiper.getMenuView().getMeasuredHeightAndState(); lp = (LayoutParams) mBeginSwiper.getMenuView().getLayoutParams();
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int parentViewWidth = getMeasuredWidthAndState(); int contentViewWidth = mContentView.getMeasuredWidthAndState(); int contentViewHeight = mContentView.getMeasuredHeightAndState(); LayoutParams lp = (LayoutParams) mContentView.getLayoutParams(); tGap + contentViewHeight); if (mEndSwiper != null) { int menuViewWidth = mEndSwiper.getMenuView().getMeasuredWidthAndState(); int menuViewHeight = mEndSwiper.getMenuView().getMeasuredHeightAndState(); lp = (LayoutParams) mEndSwiper.getMenuView().getLayoutParams(); int menuViewWidth = mBeginSwiper.getMenuView().getMeasuredWidthAndState(); int menuViewHeight = mBeginSwiper.getMenuView().getMeasuredHeightAndState(); lp = (LayoutParams) mBeginSwiper.getMenuView().getLayoutParams();
} else if (matchWidth) {//宽度填满单元格 childWidthMeasureSpec = columnNum > mRemnantWidth ? gridCellMeasureSpec_Width : gridCellMeasureSpec_WidthPlus; childHeightMeasureSpec = skipMeasure ? getChildHeightMeasureSpec(heightMeasureSpec, lp, true) : child.getMeasuredWidthAndState(); } else if (matchHeight) {//高度填满单元格 childWidthMeasureSpec = skipMeasure ? getChildWidthMeasureSpec(widthMeasureSpec, lp, true) : child.getMeasuredHeightAndState();
data.put("MeasuredHeightAndState", v.getMeasuredHeightAndState()); data.put("MeasuredState", v.getMeasuredState()); data.put("MeasuredWidthAndState", v.getMeasuredWidthAndState()); data.put("SystemUiVisibility", v.getSystemUiVisibility());//11 data.put("VerticalScrollbarPosition", v.getVerticalScrollbarPosition());//11