Java Code Examples for android.support.design.widget.CoordinatorLayout#getHeight()

The following examples show how to use android.support.design.widget.CoordinatorLayout#getHeight() . 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: SpringHeaderBehavior.java    From SpringHeader with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) {
    boolean handled = super.onLayoutChild(parent, child, layoutDirection);

    int parentHeight = parent.getHeight();
    int childHeight = child.getHeight();

    if (mOriginalOffset == UNSET) {
        setOriginalOffset(-childHeight);
    }
    if (mHoveringRange == UNSET) {
        setHoveringRange(childHeight);
    }
    if (mMaxRange == UNSET) {
        setMaxRange(parentHeight);
    }

    if (!mOriginalOffsetSet) {
        super.setTopAndBottomOffset(mOriginalOffset);
        mOriginalOffsetSet = true;
    }

    return handled;
}
 
Example 2
Source File: ViewPagerBottomSheetBehavior.java    From FabulousFilter with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: BottomSheetBehaviorV2.java    From paper-launcher with MIT License 5 votes vote down vote up
@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 4
Source File: BottomSheetBehaviorV2.java    From paper-launcher with MIT License 5 votes vote down vote up
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 5
Source File: BottomSheetBehaviorGoogleMapsLike.java    From Nibo with MIT License 5 votes vote down vote up
@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 6
Source File: BottomNavigationBehavior.java    From BottomNavigationBar with MIT License 5 votes vote down vote up
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
    if (dy > 0) {
        if (child.getY() == coordinatorLayout.getHeight() - child.getHeight()) {
            child.animate().translationY(child.getHeight()).setDuration(200).start();
        }
    } else {
        if (child.getY() == coordinatorLayout.getHeight()) {
            Log.i("etong", "onNestedPreScroll");
            child.animate().translationY(0).setDuration(250).start();
        }
    }
}
 
Example 7
Source File: ImageStreamUi.java    From belvedere with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    int scrollArea = parent.getHeight() - bottomSheetBehavior.getPeekHeight();
    float scrollPosition = (parent.getHeight() - dependency.getY() - bottomSheetBehavior.getPeekHeight()) / scrollArea;

    animateToolbarShiftIn(scrollArea, scrollPosition, ViewCompat.getMinimumHeight(toolbar), child);

    if(notifyScrollListener) {
        presenter.onImageStreamScrolled(parent.getHeight(), scrollArea, scrollPosition);
    }

    return true;
}
 
Example 8
Source File: TopSheetBehavior.java    From AndroidTopSheet with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: ViewPagerBottomSheetBehavior.java    From ViewPagerBottomSheet with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: VerticalFabBehavior.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {

    if(child.getVisibility() == View.VISIBLE&&viewY==0){
        //获取控件距离父布局(coordinatorLayout)底部距离
        viewY=coordinatorLayout.getHeight()-child.getY();
    }

    return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;//判断是否竖直滚动
}
 
Example 11
Source File: MyFabBehavior.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {

    if(child.getVisibility() == View.VISIBLE&&viewY==0){
        //获取控件距离父布局(coordinatorLayout)底部距离
        viewY=coordinatorLayout.getHeight()-child.getY();
    }

    return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;//判断是否竖直滚动
}
 
Example 12
Source File: RNBottomSheetBehavior.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@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 13
Source File: MyBottomBehavior.java    From OpenWeatherPlus-Android with Apache License 2.0 4 votes vote down vote up
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 14
Source File: AnchorSheetBehavior.java    From AnchorSheetBehavior with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
    if (getFitsSystemWindows(parent) && !getFitsSystemWindows(child)) {
        child.setFitsSystemWindows(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);
    mAnchorOffset = (int) Math.max(mParentHeight * mAnchorThreshold, mMinOffset);
    if (mState == STATE_EXPANDED) {
        offsetTopAndBottom(child, mMinOffset);
    } else if (mState == STATE_ANCHOR) {
        offsetTopAndBottom(child, mAnchorOffset);
    } else if ((mHideable && mState == STATE_HIDDEN) || mState == STATE_FORCE_HIDDEN) {
        offsetTopAndBottom(child, mParentHeight);
    } else if (mState == STATE_COLLAPSED) {
        offsetTopAndBottom(child, mMaxOffset);
    } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) {
        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 15
Source File: AnchorBottomSheetBehavior.java    From anchor-bottom-sheet-behavior with Apache License 2.0 4 votes vote down vote up
@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 16
Source File: GoogleMapsBottomSheetBehavior.java    From Google-Maps-BottomSheet with The Unlicense 4 votes vote down vote up
@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;
}