@Test public void testGoneViewsNotMeasuredLaidOut() throws Throwable { final CoordinatorLayoutActivity activity = mActivityTestRule.getActivity(); final CoordinatorLayout col = activity.mCoordinatorLayout; final View imageView = new View(activity); imageView.setVisibility(View.GONE); mActivityTestRule.runOnUiThread(new Runnable() { @Override public void run() { col.addView(imageView, 200, 200); } }); mInstrumentation.waitForIdleSync(); assertFalse(imageView.getMeasuredWidth() > 0); assertFalse(imageView.getMeasuredHeight() > 0); assertFalse(ViewCompat.isLaidOut(imageView)); mActivityTestRule.runOnUiThread(new Runnable() { @Override public void run() { imageView.setVisibility(View.INVISIBLE); } }); mInstrumentation.waitForIdleSync(); assertTrue(imageView.getMeasuredWidth() > 0); assertTrue(imageView.getMeasuredHeight() > 0); assertTrue(ViewCompat.isLaidOut(imageView)); }
@Override public void setVisibility(int visibility) { super.setVisibility(visibility); final boolean visible = visibility == VISIBLE; if (mStatusBarBackground != null && mStatusBarBackground.isVisible() != visible) { mStatusBarBackground.setVisible(visible, false); } }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override public void setVisibility(int visibility) { super.setVisibility(visibility); final boolean visible = visibility == VISIBLE; if (mStatusBarBackground != null && mStatusBarBackground.isVisible() != visible) { mStatusBarBackground.setVisible(visible, false); } } }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override public void setVisibility(int visibility) { super.setVisibility(visibility); final boolean visible = visibility == VISIBLE; if (mStatusBarBackground != null && mStatusBarBackground.isVisible() != visible) { mStatusBarBackground.setVisible(visible, false); } } CoordinatorLayout(@NonNull Context context);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr); }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override public void setVisibility(int visibility) { super.setVisibility(visibility); final boolean visible = visibility == VISIBLE; if (mStatusBarBackground != null && mStatusBarBackground.isVisible() != visible) { mStatusBarBackground.setVisible(visible, false); } } CoordinatorLayout(@NonNull Context context);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr); @Override void setOnHierarchyChangeListener(OnHierarchyChangeListener onHierarchyChangeListener); @Override void onAttachedToWindow(); @Override void onDetachedFromWindow(); void setStatusBarBackground(@Nullable final Drawable bg); @Nullable Drawable getStatusBarBackground(); @Override void setVisibility(int visibility); void setStatusBarBackgroundResource(@DrawableRes int resId); void setStatusBarBackgroundColor(@ColorInt int color); @RestrictTo(LIBRARY_GROUP) final WindowInsetsCompat getLastWindowInsets(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void requestDisallowInterceptTouchEvent(boolean disallowIntercept); void onMeasureChild(View child, int parentWidthMeasureSpec, int widthUsed,
            int parentHeightMeasureSpec, int heightUsed); void onLayoutChild(@NonNull View child, int layoutDirection); @Override void onDraw(Canvas c); @Override void setFitsSystemWindows(boolean fitSystemWindows); void dispatchDependentViewsChanged(@NonNull View view); @NonNull List<View> getDependencies(@NonNull View child); @NonNull List<View> getDependents(@NonNull View child); boolean isPointInChildBounds(@NonNull View child, int x, int y); boolean doViewsOverlap(@NonNull View first, @NonNull View second); @Override LayoutParams generateLayoutParams(AttributeSet attrs); @Override boolean onStartNestedScroll(View child, View target, int nestedScrollAxes); @Override boolean onStartNestedScroll(View child, View target, int axes, int type); @Override void onNestedScrollAccepted(View child, View target, int nestedScrollAxes); @Override void onNestedScrollAccepted(View child, View target, int nestedScrollAxes, int type); @Override void onStopNestedScroll(View target); @Override void onStopNestedScroll(View target, int type); @Override void onNestedScroll(View target, int dxConsumed, int dyConsumed,
            int dxUnconsumed, int dyUnconsumed); @Override void onNestedScroll(View target, int dxConsumed, int dyConsumed,
            int dxUnconsumed, int dyUnconsumed, int type); @Override void onNestedPreScroll(View target, int dx, int dy, int[] consumed); @Override void onNestedPreScroll(View target, int dx, int dy, int[] consumed, int  type); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override int getNestedScrollAxes(); @Override boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate); }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override public void setVisibility(int visibility) { super.setVisibility(visibility); final boolean visible = visibility == VISIBLE; if (mStatusBarBackground != null && mStatusBarBackground.isVisible() != visible) { mStatusBarBackground.setVisible(visible, false); } } CoordinatorLayout(@NonNull Context context);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs);  CoordinatorLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr); @Override void setOnHierarchyChangeListener(OnHierarchyChangeListener onHierarchyChangeListener); @Override void onAttachedToWindow(); @Override void onDetachedFromWindow(); void setStatusBarBackground(@Nullable final Drawable bg); @Nullable Drawable getStatusBarBackground(); @Override void setVisibility(int visibility); void setStatusBarBackgroundResource(@DrawableRes int resId); void setStatusBarBackgroundColor(@ColorInt int color); @RestrictTo(LIBRARY_GROUP) final WindowInsetsCompat getLastWindowInsets(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void requestDisallowInterceptTouchEvent(boolean disallowIntercept); void onMeasureChild(View child, int parentWidthMeasureSpec, int widthUsed,
            int parentHeightMeasureSpec, int heightUsed); void onLayoutChild(@NonNull View child, int layoutDirection); @Override void onDraw(Canvas c); @Override void setFitsSystemWindows(boolean fitSystemWindows); void dispatchDependentViewsChanged(@NonNull View view); @NonNull List<View> getDependencies(@NonNull View child); @NonNull List<View> getDependents(@NonNull View child); boolean isPointInChildBounds(@NonNull View child, int x, int y); boolean doViewsOverlap(@NonNull View first, @NonNull View second); @Override LayoutParams generateLayoutParams(AttributeSet attrs); @Override boolean onStartNestedScroll(View child, View target, int nestedScrollAxes); @Override boolean onStartNestedScroll(View child, View target, int axes, int type); @Override void onNestedScrollAccepted(View child, View target, int nestedScrollAxes); @Override void onNestedScrollAccepted(View child, View target, int nestedScrollAxes, int type); @Override void onStopNestedScroll(View target); @Override void onStopNestedScroll(View target, int type); @Override void onNestedScroll(View target, int dxConsumed, int dyConsumed,
            int dxUnconsumed, int dyUnconsumed); @Override void onNestedScroll(View target, int dxConsumed, int dyConsumed,
            int dxUnconsumed, int dyUnconsumed, int type); @Override void onNestedPreScroll(View target, int dx, int dy, int[] consumed); @Override void onNestedPreScroll(View target, int dx, int dy, int[] consumed, int  type); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override int getNestedScrollAxes(); @Override boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate);  }