Java Code Examples for android.support.design.widget.CoordinatorLayout#onLayoutChild()
The following examples show how to use
android.support.design.widget.CoordinatorLayout#onLayoutChild() .
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: BottomVerticalScrollBehavior.java From JD-Test with Apache License 2.0 | 6 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, final V child, int layoutDirection) { // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); if (child instanceof BottomNavigationBar) { mViewRef = new WeakReference<>((BottomNavigationBar) child); } child.post(new Runnable() { @Override public void run() { mBottomNavHeight = child.getHeight(); } }); updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child)); return super.onLayoutChild(parent, child, layoutDirection); }
Example 2
Source File: BottomNavBarFabBehaviour.java From JD-Test with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, FloatingActionButton child, int layoutDirection) { // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); updateFabTranslationForBottomNavigationBar(parent, child, null); return super.onLayoutChild(parent, child, layoutDirection); }
Example 3
Source File: UcNewsTitleBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { // FIXME: 16/7/27 不知道为啥在XML设置-45dip,解析出来的topMargin少了1个px,所以这里用代码设置一遍 ((CoordinatorLayout.LayoutParams) child.getLayoutParams()).topMargin = -getTitleHeight(); parent.onLayoutChild(child, layoutDirection); if (BuildConfig.DEBUG) { Log.d(TAG, "layoutChild:top" + child.getTop() + ",height" + child.getHeight()); } return true; }
Example 4
Source File: ViewPagerBottomSheetBehavior.java From ViewPagerBottomSheet with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 5
Source File: TopSheetBehavior.java From AndroidTopSheet with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); mMinOffset = Math.max(-child.getHeight(), -(child.getHeight() - mPeekHeight)); mMaxOffset = 0; if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, -child.getHeight()); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 6
Source File: QQBrowserTitleBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { // FIXME: 16/7/27 不知道为啥在XML设置-45dip,解析出来的topMargin少了1个px,所以这里用代码设置一遍 ((CoordinatorLayout.LayoutParams) child.getLayoutParams()).topMargin = -getTitleHeight(); parent.onLayoutChild(child, layoutDirection); if (BuildConfig.DEBUG) { Log.d(TAG, "layoutChild:top" + child.getTop() + ",height" + child.getHeight()); } return true; }
Example 7
Source File: BottomSheetBehaviorGoogleMapsLike.java From Nibo with MIT License | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { // First let the parent lay it out if (mState != STATE_DRAGGING && mState != STATE_SETTLING) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } parent.onLayoutChild(child, layoutDirection); } // Offset the bottom sheet mParentHeight = parent.getHeight(); mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset); /** * New behavior */ if (mState == STATE_ANCHOR_POINT) { ViewCompat.offsetTopAndBottom(child, mAnchorPoint); } else if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 8
Source File: FabSpeedDialBehaviour.java From fab-speed-dial with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, FabSpeedDial child, int layoutDirection) { // First, lets 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 && updateFabVisibility(parent, (AppBarLayout) dependency, child)) { break; } } // Now let the CoordinatorLayout lay out the FAB parent.onLayoutChild(child, layoutDirection); return true; }
Example 9
Source File: BottomSheetBehaviorV2.java From paper-launcher with MIT License | 5 votes |
public boolean onLayoutChildFixed(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( android.support.design.R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 10
Source File: BottomSheetBehaviorV2.java From paper-launcher with MIT License | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( android.support.design.R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 11
Source File: FabSpeedDialBehaviour.java From fab-speed-dial with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, FabSpeedDial child, int layoutDirection) { // First, lets 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 && updateFabVisibility(parent, (AppBarLayout) dependency, child)) { break; } } // Now let the CoordinatorLayout lay out the FAB parent.onLayoutChild(child, layoutDirection); return true; }
Example 12
Source File: RecyclerViewBehavior.java From timecat with Apache License 2.0 | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, RecyclerView child, int layoutDirection) { parent.onLayoutChild(child, layoutDirection); MonthPager monthPager = getMonthPager(parent); initMinOffsetAndInitOffset(parent, child, monthPager); return true; }
Example 13
Source File: RNBottomSheetBehavior.java From react-native-bottom-sheet-behavior with MIT License | 5 votes |
@Override public boolean onLayoutChild( CoordinatorLayout parent, V child, int layoutDirection ) { // First let the parent lay it out if (mState != STATE_DRAGGING && mState != STATE_SETTLING) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } parent.onLayoutChild(child, layoutDirection); } // Offset the bottom sheet mParentHeight = parent.getHeight(); mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset); /** * New behavior */ if (mAnchorEnabled && mState == STATE_ANCHOR_POINT) { toggleHeaderColor(true); ViewCompat.offsetTopAndBottom(child, mAnchorPoint); } else if (mState == STATE_EXPANDED) { toggleHeaderColor(true); ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { toggleHeaderColor(false); ViewCompat.offsetTopAndBottom(child, mMaxOffset); } if ( mViewDragHelper == null ) { mViewDragHelper = ViewDragHelper.create( parent, mDragCallback ); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>( findScrollingChild( child ) ); return true; }
Example 14
Source File: SlidingCardBehavior.java From coordinated-effort with MIT License | 5 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, SlidingCardLayout child, int layoutDirection) { parent.onLayoutChild(child, layoutDirection); SlidingCardLayout previous = getPreviousChild(parent, child); if (previous != null) { int offset = previous.getTop() + previous.getHeaderHeight(); child.offsetTopAndBottom(offset); } mInitialOffset = child.getTop(); return true; }
Example 15
Source File: ViewOffsetBehavior.java From UCMainViewForBehavior with Apache License 2.0 | 4 votes |
protected void layoutChild(CoordinatorLayout parent, V child, int layoutDirection) { // Let the parent lay it out by default parent.onLayoutChild(child, layoutDirection); }
Example 16
Source File: MyBottomBehavior.java From OpenWeatherPlus-Android with Apache License 2.0 | 4 votes |
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { child.setFitsSystemWindows(true); } int savedTop = child.getTop(); parent.onLayoutChild(child, layoutDirection); this.parentHeight = parent.getHeight(); if (this.peekHeightAuto) { if (this.peekHeightMin == 0) { this.peekHeightMin = parent.getResources().getDimensionPixelSize(dimen.design_bottom_sheet_peek_height_min); } this.lastPeekHeight = Math.max(this.peekHeightMin, this.parentHeight - parent.getWidth() * 9 / 16); } else { this.lastPeekHeight = this.peekHeight; } this.fitToContentsOffset = Math.max(0, this.parentHeight - child.getHeight()); this.halfExpandedOffset = parent.getHeight() - DisplayUtil.dip2px(MyApplication.getInstance(), 470); this.calculateCollapsedOffset(); if (this.state == 3) { ViewCompat.offsetTopAndBottom(child, this.getExpandedOffset()); } else if (this.state == 6) { ViewCompat.offsetTopAndBottom(child, this.halfExpandedOffset); } else if (this.hideable && this.state == 5) { ViewCompat.offsetTopAndBottom(child, this.parentHeight); } else if (this.state == 4) { ViewCompat.offsetTopAndBottom(child, this.collapsedOffset); } else if (this.state == 1 || this.state == 2) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (this.viewDragHelper == null) { this.viewDragHelper = ViewDragHelper.create(parent, this.dragCallback); } this.viewRef = new WeakReference(child); this.nestedScrollingChildRef = new WeakReference(this.findScrollingChild(child)); return true; }
Example 17
Source File: ViewOffsetBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
protected void layoutChild(CoordinatorLayout parent, V child, int layoutDirection) { // Let the parent lay it out by default parent.onLayoutChild(child, layoutDirection); }
Example 18
Source File: AnchorBottomSheetBehavior.java From anchor-bottom-sheet-behavior with Apache License 2.0 | 4 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( android.support.design.R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); if (mDisableExpanded) { mMinOffset = mAnchorOffset; } mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } else if (mState == STATE_ANCHORED) { if (mAnchorOffset > mMinOffset) { ViewCompat.offsetTopAndBottom(child, mAnchorOffset); } else { mState = STATE_EXPANDED; ViewCompat.offsetTopAndBottom(child, mMinOffset); } } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
Example 19
Source File: GoogleMapsBottomSheetBehavior.java From Google-Maps-BottomSheet with The Unlicense | 4 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize(R.dimen.peekHeightMin); } mPeekHeight = mPeekHeightMin; } if (mAnchorHeightAuto) { if (mAnchorHeightMin == 0) { mAnchorHeightMin = mParentHeight - parent.getWidth() * 9 / 16; } mAnchorHeight = mAnchorHeightMin; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset); mAnchorOffset = Math.min(mParentHeight - mAnchorHeight, mMaxOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); updateHeaderColor(mAnchorColor, mAnchorTextColor); anchorViews(mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); anchorViews(mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); anchorViews(mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } else if (mState == STATE_ANCHORED) { ViewCompat.offsetTopAndBottom(child, mAnchorOffset); updateHeaderColor(mAnchorColor, mAnchorTextColor); if (parallax != null) { int reference = savedTop - parallax.getHeight(); parallax.setY(reference); parallax.setVisibility(View.VISIBLE); anchorViews(reference); } else { anchorViews(mAnchorOffset); } } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); // add missing views to the layout ViewGroup nestedScrolling = (ViewGroup) mNestedScrollingChildRef.get(); if (nestedScrolling.getChildCount() == 0) { nestedScrolling.addView(bottomsheet); } return true; }
Example 20
Source File: ViewOffsetBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
protected void layoutChild(CoordinatorLayout parent, V child, int layoutDirection) { parent.onLayoutChild(child, layoutDirection); }