Java Code Examples for android.support.design.widget.AppBarLayout#getMeasuredHeight()

The following examples show how to use android.support.design.widget.AppBarLayout#getMeasuredHeight() . 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: NestedTouchScrollingLayout.java    From NestedTouchScrollingLayout with MIT License 5 votes vote down vote up
/**
 * child can scroll
 * @param view
 * @param event
 * @param x
 * @param y
 * @param lockRect 是否开启 touch 所动在当前 view 区域
 * @return
 */
protected boolean canScrollUp(View view, MotionEvent event, float x, float y, boolean lockRect) {

    if (view instanceof WebView) {
        return canWebViewScrollUp((WebView) view);
    }
    if (view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);
            int childLeft = child.getLeft() - view.getScrollX();
            int childTop = child.getTop() - view.getScrollY();
            int childRight = child.getRight() - view.getScrollX();
            int childBottom = child.getBottom() - view.getScrollY();
            boolean intersects = x > childLeft && x < childRight && y > childTop && y < childBottom;
            if ((!lockRect || intersects)
                    && canScrollUp(child, event, x - childLeft, y - childTop, lockRect)) {
                return true;
            }
        }
    }

    if (view instanceof CoordinatorLayout &&
            ((CoordinatorLayout) view).getChildCount() > 0 &&
            ((CoordinatorLayout) view).getChildAt(0) instanceof AppBarLayout) {
        AppBarLayout layout = (AppBarLayout) ((CoordinatorLayout) view).getChildAt(0);
        OnNestOffsetChangedListener listener = mOnOffsetChangedListener.get(layout.hashCode());
        if (listener != null) {
            if (listener.getOffsetY() < layout.getMeasuredHeight() && listener.getOffsetY() > 0) {
                return true;
            }
        }
    }

    return isTouchUnderChildView(view, event) && view.canScrollVertically(-1);
}
 
Example 2
Source File: NestedTouchScrollingLayout.java    From NestedTouchScrollingLayout with MIT License 5 votes vote down vote up
/**
 * child can scroll
 * @param view
 * @param event
 * @param x
 * @param y
 * @param lockRect 是否开启 touch 所动在当前 view 区域
 * @return
 */
protected boolean canScrollDown(View view, MotionEvent event, float x, float y, boolean lockRect) {
    if (view instanceof WebView) {
        return canWebViewScrollDown((WebView) view);
    }
    if (view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);
            int childLeft = child.getLeft() - view.getScrollX();
            int childTop = child.getTop() - view.getScrollY();
            int childRight = child.getRight() - view.getScrollX();
            int childBottom = child.getBottom() - view.getScrollY();
            boolean intersects = x > childLeft && x < childRight && y > childTop && y < childBottom;
            if ((!lockRect || intersects)
                    && canScrollDown(child, event, x - childLeft, y - childTop, lockRect)) {
                return true;
            }
        }
    }

    if (view instanceof CoordinatorLayout &&
            ((CoordinatorLayout) view).getChildCount() > 0 &&
            ((CoordinatorLayout) view).getChildAt(0) instanceof AppBarLayout) {
        AppBarLayout layout = (AppBarLayout) ((CoordinatorLayout) view).getChildAt(0);
        OnNestOffsetChangedListener listener = mOnOffsetChangedListener.get(layout.hashCode());
        if (listener != null) {
            if (listener.getOffsetY() < layout.getMeasuredHeight() && listener.getOffsetY() > 0) {
                return true;
            }
        }
    }

    return isTouchUnderChildView(view, event) && view.canScrollVertically(1);
}
 
Example 3
Source File: SmoothAppBarLayout.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
protected int getMinOffset(AppBarLayout layout) {
  int minOffset = layout.getMeasuredHeight();
  if (mScrollFlag != null) {
    if (mScrollFlag.isFlagScrollEnabled()) {
      minOffset = layout.getMeasuredHeight() - getMinHeight(layout, false);
    }
  }
  if (ViewCompat.getFitsSystemWindows(layout)) {
    if (mStatusBarSize == 0) {
      mStatusBarSize = Utils.getStatusBarSize(layout.getContext());
    }
    minOffset -= mStatusBarSize;
  }
  return -Math.max(minOffset, 0);
}
 
Example 4
Source File: SmoothAppBarLayout.java    From smooth-app-bar-layout with Apache License 2.0 5 votes vote down vote up
protected int getMinOffset(AppBarLayout layout) {
  int minOffset = layout.getMeasuredHeight();
  if (mScrollFlag != null) {
    if (mScrollFlag.isFlagScrollEnabled()) {
      minOffset = layout.getMeasuredHeight() - getMinHeight(layout, false);
    }
  }
  if (ViewCompat.getFitsSystemWindows(layout)) {
    if (mStatusBarSize == 0) {
      mStatusBarSize = Utils.getStatusBarSize(layout.getContext());
    }
    minOffset -= mStatusBarSize;
  }
  return -Math.max(minOffset, 0);
}