@Test public void testDodgeInsetBeforeLayout() throws Throwable { final CoordinatorLayout col = mActivityTestRule.getActivity().mCoordinatorLayout; final View dummy = new View(col.getContext()); mActivityTestRule.runOnUiThread(new Runnable() { @Override public void run() { col.addView(dummy); } }); mInstrumentation.waitForIdleSync(); final View dodge = new View(col.getContext()); final CoordinatorLayout.LayoutParams lpDodge = col.generateDefaultLayoutParams(); lpDodge.dodgeInsetEdges = Gravity.BOTTOM; lpDodge.setBehavior(new CoordinatorLayout.Behavior() { @Override public boolean getInsetDodgeRect(CoordinatorLayout parent, View child, Rect rect) { rect.set(0, 0, 10, 10); return true; } }); mActivityTestRule.runOnUiThread(new Runnable() { @Override public void run() { col.addView(dodge, lpDodge); int heightSpec = MeasureSpec.makeMeasureSpec(col.getHeight(), MeasureSpec.EXACTLY); int widthSpec = MeasureSpec.makeMeasureSpec(col.getWidth(), MeasureSpec.EXACTLY); col.measure(widthSpec, heightSpec); col.removeView(dummy); } }); mInstrumentation.waitForIdleSync(); }
@Override protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } }
CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { @Override protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } 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 protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } 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 protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } 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);  }