Java Code Examples for androidx.coordinatorlayout.widget.CoordinatorLayout#getDependencies()
The following examples show how to use
androidx.coordinatorlayout.widget.CoordinatorLayout#getDependencies() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtendedFloatingActionButton.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public boolean onLayoutChild( @NonNull CoordinatorLayout parent, @NonNull ExtendedFloatingActionButton child, int layoutDirection) { // First, let's make sure that the visibility of the FAB is consistent final List<View> dependencies = parent.getDependencies(child); for (int i = 0, count = dependencies.size(); i < count; i++) { final View dependency = dependencies.get(i); if (dependency instanceof AppBarLayout) { if (updateFabVisibilityForAppBarLayout(parent, (AppBarLayout) dependency, child)) { break; } } else if (isBottomSheet(dependency)) { if (updateFabVisibilityForBottomSheet(dependency, child)) { break; } } } // Now let the CoordinatorLayout lay out the FAB parent.onLayoutChild(child, layoutDirection); return true; }
Example 2
Source File: FloatingActionButton.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public boolean onLayoutChild( @NonNull CoordinatorLayout parent, @NonNull FloatingActionButton child, int layoutDirection) { // First, let's make sure that the visibility of the FAB is consistent final List<View> dependencies = parent.getDependencies(child); for (int i = 0, count = dependencies.size(); i < count; i++) { final View dependency = dependencies.get(i); if (dependency instanceof AppBarLayout) { if (updateFabVisibilityForAppBarLayout(parent, (AppBarLayout) dependency, child)) { break; } } else if (isBottomSheet(dependency)) { if (updateFabVisibilityForBottomSheet(dependency, child)) { break; } } } // Now let the CoordinatorLayout lay out the FAB parent.onLayoutChild(child, layoutDirection); // Now offset it if needed offsetIfNeeded(parent, child); return true; }
Example 3
Source File: BottomNavBarFabBehaviour.java From BottomNavigation with Apache License 2.0 | 6 votes |
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; float viewHeight = 0; final List<View> dependencies = parent.getDependencies(fab); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof BottomNavigationBar) { viewHeight = view.getHeight(); minOffset = Math.min(minOffset, view.getTranslationY() - viewHeight); } } return new float[]{minOffset, viewHeight}; }
Example 4
Source File: FABMenu.java From Jockey with Apache License 2.0 | 6 votes |
private float getFabTranslationYForSnackbar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0.0F; List dependencies = parent.getDependencies(fab); int i = 0; for (int z = dependencies.size(); i < z; ++i) { View view = (View) dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(fab, view)) { minOffset = Math.min( minOffset, view.getTranslationY() - (float) view.getHeight()); } } return minOffset; }
Example 5
Source File: EhDrawerLayout.java From MHViewer with Apache License 2.0 | 5 votes |
private float getChildTranslationYForSnackbar(CoordinatorLayout parent, EhDrawerLayout child) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(child); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) { minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - view.getHeight()); } } return minOffset; }
Example 6
Source File: AppBarBoundFabBehavior.java From appbarsyncedfab with Apache License 2.0 | 5 votes |
/** * returns visible height of snackbar, if snackbar is overlapping fab * 0 otherwise */ private float getVisibleHeightOfOverlappingSnackbar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(fab); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(fab, view)) { minOffset = Math.min(minOffset, view.getTranslationY() - view.getHeight()); } } return minOffset; }
Example 7
Source File: ExpandableBehavior.java From material-components-android with Apache License 2.0 | 5 votes |
@Nullable protected ExpandableWidget findExpandableWidget( @NonNull CoordinatorLayout parent, @NonNull View child) { List<View> dependencies = parent.getDependencies(child); for (int i = 0, size = dependencies.size(); i < size; i++) { View dependency = dependencies.get(i); if (layoutDependsOn(parent, child, dependency)) { return (ExpandableWidget) dependency; } } return null; }
Example 8
Source File: BottomVerticalScrollBehavior.java From BottomNavigation with Apache License 2.0 | 5 votes |
private Snackbar.SnackbarLayout getSnackBarInstance(CoordinatorLayout parent, V child) { final List<View> dependencies = parent.getDependencies(child); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout) { return (Snackbar.SnackbarLayout) view; } } return null; }
Example 9
Source File: BottomNavBarFabBehaviour.java From BottomNavigation with Apache License 2.0 | 5 votes |
private float getFabTranslationYForSnackBar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(fab); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(fab, view)) { minOffset = Math.min(minOffset, view.getTranslationY() - view.getHeight()); } } return minOffset; }
Example 10
Source File: EhDrawerLayout.java From EhViewer with Apache License 2.0 | 5 votes |
private float getChildTranslationYForSnackbar(CoordinatorLayout parent, EhDrawerLayout child) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(child); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) { minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - view.getHeight()); } } return minOffset; }
Example 11
Source File: SnackbarBehavior.java From CircleIndicator with Apache License 2.0 | 5 votes |
private float getTranslationYForSnackbar(CoordinatorLayout parent, BaseCircleIndicator ci) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(ci); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(ci, view)) { minOffset = Math.min(minOffset, view.getTranslationY() - view.getHeight()); } } return minOffset; }
Example 12
Source File: HeaderScrollingViewBehavior.java From material-components-android with Apache License 2.0 | 4 votes |
@Override protected void layoutChild( @NonNull final CoordinatorLayout parent, @NonNull final View child, final int layoutDirection) { final List<View> dependencies = parent.getDependencies(child); final View header = findFirstDependency(dependencies); if (header != null) { final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); final Rect available = tempRect1; available.set( parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, parent.getWidth() - parent.getPaddingRight() - lp.rightMargin, parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin); final WindowInsetsCompat parentInsets = parent.getLastWindowInsets(); if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent) && !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 horizontally. // Top and bottom and already handled in the logic above available.left += parentInsets.getSystemWindowInsetLeft(); available.right -= parentInsets.getSystemWindowInsetRight(); } final Rect out = tempRect2; GravityCompat.apply( resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection); final int overlap = getOverlapPixelsForOffset(header); child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap); verticalLayoutGap = out.top - header.getBottom(); } else { // If we don't have a dependency, let super handle it super.layoutChild(parent, child, layoutDirection); verticalLayoutGap = 0; } }