当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.getMinimumHeight方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.getMinimumHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.getMinimumHeight方法的具体用法?Java ViewCompat.getMinimumHeight怎么用?Java ViewCompat.getMinimumHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.getMinimumHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScrimVisibleHeightTrigger

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Returns the amount of visible height in pixels used to define when to trigger a scrim
 * visibility change.
 *
 * @see #setScrimVisibleHeightTrigger(int)
 */
public int getScrimVisibleHeightTrigger() {
    if (mScrimVisibleHeightTrigger >= 0) {
        // If we have one explicitly set, return it
        return mScrimVisibleHeightTrigger;
    }

    // Otherwise we'll use the default computed value
    final int insetTop = mLastInsets != null ? mLastInsets.getSystemWindowInsetTop() : 0;

    final int minHeight = ViewCompat.getMinimumHeight(this);
    if (minHeight > 0) {
        // If we have a minHeight set, lets use 2 * minHeight (capped at our height)
        return Math.min((minHeight * 2) + insetTop, getHeight());
    }

    // If we reach here then we don't have a min height set. Instead we'll take a
    // guess at 1/3 of our height being visible
    return getHeight() / 3;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:26,代码来源:QMUICollapsingTopBarLayout.java

示例2: onSaveInstanceState

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public Parcelable onSaveInstanceState(CoordinatorLayout parent, AppBarLayout abl) {
  final Parcelable superState = super.onSaveInstanceState(parent, abl);
  final int offset = getTopAndBottomOffset();

  // Try and find the first visible child...
  for (int i = 0, count = abl.getChildCount(); i < count; i++) {
    View child = abl.getChildAt(i);
    final int visBottom = child.getBottom() + offset;

    if (child.getTop() + offset <= 0 && visBottom >= 0) {
      final SavedState ss = new SavedState(superState);
      ss.firstVisibleChildIndex = i;
      ss.firstVisibleChildAtMinimumHeight =
          visBottom == (ViewCompat.getMinimumHeight(child) + abl.getTopInset());
      ss.firstVisibleChildPercentageShown = visBottom / (float) child.getHeight();
      return ss;
    }
  }

  // Else we'll just return the super state
  return superState;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:24,代码来源:AppBarLayout.java

示例3: onSaveInstanceState

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public Parcelable onSaveInstanceState(CoordinatorLayout parent, AppBarLayout appBarLayout) {
    Parcelable superState = super.onSaveInstanceState(parent, appBarLayout);
    int offset = getTopAndBottomOffset();
    int i = 0;
    int count = appBarLayout.getChildCount();
    while (i < count) {
        View child = appBarLayout.getChildAt(i);
        int visBottom = child.getBottom() + offset;
        if (child.getTop() + offset > 0 || visBottom < 0) {
            i++;
        } else {
            SavedState ss = new SavedState(superState);
            ss.firstVisibleChildIndex = i;
            ss.firstVisibileChildAtMinimumHeight = visBottom == ViewCompat.getMinimumHeight(child);
            ss.firstVisibileChildPercentageShown = ((float) visBottom) / ((float) child.getHeight());
            return ss;
        }
    }
    return superState;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AppBarLayout.java

示例4: onOffsetChanged

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout layout, int verticalOffset) {
    mCurrentOffset = verticalOffset;

    final int insetTop = mLastInsets != null ? mLastInsets.getSystemWindowInsetTop() : 0;

    for (int i = 0, z = getChildCount(); i < z; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final QMUIViewOffsetHelper offsetHelper = getViewOffsetHelper(child);

        switch (lp.mCollapseMode) {
            case QMUICollapsingTopBarLayout.LayoutParams.COLLAPSE_MODE_PIN:
                offsetHelper.setTopAndBottomOffset(
                        QMUILangHelper.constrain(-verticalOffset, 0, getMaxOffsetForPinChild(child)));
                break;
            case QMUICollapsingTopBarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX:
                offsetHelper.setTopAndBottomOffset(
                        Math.round(-verticalOffset * lp.mParallaxMult));
                break;
        }
    }

    // Show or hide the scrims if needed
    updateScrimVisibility();

    if (mStatusBarScrim != null && insetTop > 0) {
        ViewCompat.postInvalidateOnAnimation(QMUICollapsingTopBarLayout.this);
    }

    // Update the collapsing text's fraction
    final int expandRange = getHeight() - ViewCompat.getMinimumHeight(
            QMUICollapsingTopBarLayout.this) - insetTop;
    mCollapsingTextHelper.setExpansionFraction(
            Math.abs(verticalOffset) / (float) expandRange);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:37,代码来源:QMUICollapsingTopBarLayout.java

示例5: getTotalScrollRange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Returns the scroll range of all children.
 *
 * @return the scroll range in px
 */
public final int getTotalScrollRange() {
  if (mTotalScrollRange != INVALID_SCROLL_RANGE) {
    return mTotalScrollRange;
  }

  int range = 0;
  for (int i = 0, z = getChildCount(); i < z; i++) {
    final View child = getChildAt(i);
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    final int childHeight = child.getMeasuredHeight();
    final int flags = lp.mScrollFlags;

    if ((flags & LayoutParams.SCROLL_FLAG_SCROLL) != 0) {
      // We're set to scroll so add the child's height
      range += childHeight + lp.topMargin + lp.bottomMargin;

      if ((flags & LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) != 0) {
        // For a collapsing scroll, we to take the collapsed height into account.
        // We also break straight away since later views can't scroll beneath
        // us
        range -= ViewCompat.getMinimumHeight(child);
        break;
      }
    } else {
      // As soon as a view doesn't have the scroll flag, we end the range calculation.
      // This is because views below can not scroll under a fixed view.
      break;
    }
  }
  return mTotalScrollRange = Math.max(0, range - getTopInset());
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:37,代码来源:AppBarLayout.java

示例6: getDownNestedPreScrollRange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
   * Return the scroll range when scrolling down from a nested pre-scroll.
   */
int getDownNestedPreScrollRange() {
  if (mDownPreScrollRange != INVALID_SCROLL_RANGE) {
    // If we already have a valid value, return it
    return mDownPreScrollRange;
  }

  int range = 0;
  for (int i = getChildCount() - 1; i >= 0; i--) {
    final View child = getChildAt(i);
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    final int childHeight = child.getMeasuredHeight();
    final int flags = lp.mScrollFlags;

    if ((flags & LayoutParams.FLAG_QUICK_RETURN) == LayoutParams.FLAG_QUICK_RETURN) {
      // First take the margin into account
      range += lp.topMargin + lp.bottomMargin;
      // The view has the quick return flag combination...
      if ((flags & LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED) != 0) {
        // If they're set to enter collapsed, use the minimum height
        range += ViewCompat.getMinimumHeight(child);
      } else if ((flags & LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) != 0) {
        // Only enter by the amount of the collapsed height
        range += childHeight - ViewCompat.getMinimumHeight(child);
      } else {
                  // Else use the full height (minus the top inset)
                  range += childHeight - getTopInset();
      }
    } else if (range > 0) {
      // If we've hit an non-quick return scrollable view, and we've already hit a
      // quick return view, return now
      break;
    }
  }
  return mDownPreScrollRange = Math.max(0, range);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:39,代码来源:AppBarLayout.java

示例7: getDownNestedScrollRange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
   * Return the scroll range when scrolling down from a nested scroll.
   */
int getDownNestedScrollRange() {
  if (mDownScrollRange != INVALID_SCROLL_RANGE) {
    // If we already have a valid value, return it
    return mDownScrollRange;
  }

  int range = 0;
  for (int i = 0, z = getChildCount(); i < z; i++) {
    final View child = getChildAt(i);
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    int childHeight = child.getMeasuredHeight();
    childHeight += lp.topMargin + lp.bottomMargin;

    final int flags = lp.mScrollFlags;

    if ((flags & LayoutParams.SCROLL_FLAG_SCROLL) != 0) {
      // We're set to scroll so add the child's height
      range += childHeight;

      if ((flags & LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) != 0) {
        // For a collapsing exit scroll, we to take the collapsed height into account.
        // We also break the range straight away since later views can't scroll
        // beneath us
        range -= ViewCompat.getMinimumHeight(child) + getTopInset();
        break;
      }
    } else {
      // As soon as a view doesn't have the scroll flag, we end the range calculation.
      // This is because views below can not scroll under a fixed view.
      break;
    }
  }
  return mDownScrollRange = Math.max(0, range);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:38,代码来源:AppBarLayout.java

示例8: getMinimumHeightForVisibleOverlappingContent

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
final int getMinimumHeightForVisibleOverlappingContent() {
    int topInset = getTopInset();
    int minHeight = ViewCompat.getMinimumHeight(this);
    if (minHeight != 0) {
        return (minHeight * 2) + topInset;
    }
    int childCount = getChildCount();
    return childCount >= 1 ? (ViewCompat.getMinimumHeight(getChildAt(childCount - 1)) * 2) + topInset : 0;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:AppBarLayout.java

示例9: updateAppBarLayoutDrawableState

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateAppBarLayoutDrawableState(final CoordinatorLayout parent,
            final AppBarLayout layout, final int offset, final int direction,
            final boolean forceJump) {
  final View child = getAppBarChildOnOffset(layout, offset);
  if (child != null) {
            final AppBarLayout.LayoutParams childLp = (LayoutParams) child.getLayoutParams();
    final int flags = childLp.getScrollFlags();
    boolean collapsed = false;

    if ((flags & LayoutParams.SCROLL_FLAG_SCROLL) != 0) {
      final int minHeight = ViewCompat.getMinimumHeight(child);

                if (direction > 0 && (flags & (LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
                        | LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED)) != 0) {
        // We're set to enter always collapsed so we are only collapsed when
        // being scrolled down, and in a collapsed offset
        collapsed = -offset >= child.getBottom() - minHeight - layout.getTopInset();
      } else if ((flags & LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) != 0) {
        // We're set to exit until collapsed, so any offset which results in
        // the minimum height (or less) being shown is collapsed
        collapsed = -offset >= child.getBottom() - minHeight - layout.getTopInset();
      }
    }

    final boolean changed = layout.setCollapsedState(collapsed);

            if (Build.VERSION.SDK_INT >= 11 && (forceJump
                    || (changed && shouldJumpElevationState(parent, layout)))) {
      // If the collapsed state changed, we may need to
      // jump to the current state if we have an overlapping view
      layout.jumpDrawablesToCurrentState();
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:35,代码来源:AppBarLayout.java

示例10: getMinHeight

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private int getMinHeight(AppBarLayout layout, boolean forceQuickReturn) {
  int minHeight = ViewCompat.getMinimumHeight(layout);
  if (mScrollFlag.isFlagExitUntilCollapsedEnabled() || (minHeight > 0 && !mScrollFlag.isQuickReturnEnabled()) || forceQuickReturn) {
    return minHeight > 0 ? minHeight : ViewCompat.getMinimumHeight(mScrollFlag.getView());
  }
  return 0;
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:8,代码来源:SmoothAppBarLayout.java

示例11: getDownNestedPreScrollRange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private int getDownNestedPreScrollRange() {
    if (this.mDownPreScrollRange != -1) {
        return this.mDownPreScrollRange;
    }
    int range = 0;
    for (int i = getChildCount() - 1; i >= 0; i--) {
        View child = getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        int childHeight = child.getMeasuredHeight();
        int flags = lp.mScrollFlags;
        if ((flags & 5) == 5) {
            range += lp.topMargin + lp.bottomMargin;
            if ((flags & 8) != 0) {
                range += ViewCompat.getMinimumHeight(child);
            } else if ((flags & 2) != 0) {
                range += childHeight - ViewCompat.getMinimumHeight(child);
            } else {
                range += childHeight;
            }
        } else if (range > 0) {
            break;
        }
    }
    int max = Math.max(0, range - getTopInset());
    this.mDownPreScrollRange = max;
    return max;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:AppBarLayout.java

示例12: interpolateOffset

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private int interpolateOffset(AppBarLayout layout, int offset) {
    int absOffset = Math.abs(offset);
    int i = 0;
    int z = layout.getChildCount();
    while (i < z) {
        View child = layout.getChildAt(i);
        LayoutParams childLp = (LayoutParams) child.getLayoutParams();
        Interpolator interpolator = childLp.getScrollInterpolator();
        if (absOffset < child.getTop() || absOffset > child.getBottom()) {
            i++;
        } else if (interpolator == null) {
            return offset;
        } else {
            int childScrollableHeight = 0;
            int flags = childLp.getScrollFlags();
            if ((flags & 1) != 0) {
                childScrollableHeight = 0 + ((child.getHeight() + childLp.topMargin) + childLp.bottomMargin);
                if ((flags & 2) != 0) {
                    childScrollableHeight -= ViewCompat.getMinimumHeight(child);
                }
            }
            if (ViewCompat.getFitsSystemWindows(child)) {
                childScrollableHeight -= layout.getTopInset();
            }
            if (childScrollableHeight <= 0) {
                return offset;
            }
            return Integer.signum(offset) * (child.getTop() + Math.round(((float) childScrollableHeight) * interpolator.getInterpolation(((float) (absOffset - child.getTop())) / ((float) childScrollableHeight))));
        }
    }
    return offset;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:AppBarLayout.java

示例13: onOffsetChanged

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout layout, int verticalOffset) {
    mCurrentOffset = verticalOffset;

    final int insetTop = getWindowInsetTop();

    for (int i = 0, z = getChildCount(); i < z; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final QMUIViewOffsetHelper offsetHelper = getViewOffsetHelper(child);

        switch (lp.mCollapseMode) {
            case QMUICollapsingTopBarLayout.LayoutParams.COLLAPSE_MODE_PIN:
                offsetHelper.setTopAndBottomOffset(
                        QMUILangHelper.constrain(-verticalOffset, 0, getMaxOffsetForPinChild(child)));
                break;
            case QMUICollapsingTopBarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX:
                offsetHelper.setTopAndBottomOffset(
                        Math.round(-verticalOffset * lp.mParallaxMult));
                break;
        }
    }

    // Show or hide the scrims if needed
    updateScrimVisibility();

    if (mStatusBarScrim != null && insetTop > 0) {
        ViewCompat.postInvalidateOnAnimation(QMUICollapsingTopBarLayout.this);
    }

    // Update the collapsing text's fraction
    final int expandRange = getHeight() - ViewCompat.getMinimumHeight(
            QMUICollapsingTopBarLayout.this) - insetTop;
    mCollapsingTextHelper.setExpansionFraction(
            Math.abs(verticalOffset) / (float) expandRange);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:37,代码来源:QMUICollapsingTopBarLayout.java

示例14: getMinimumHeight

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * @return The host RecyclerView's {@link View#getMinimumHeight()}
 */
public int getMinimumHeight() {
    return ViewCompat.getMinimumHeight(mRecyclerView);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:7,代码来源:RecyclerView.java

示例15: getMinimumHeight

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public int getMinimumHeight() {
    return ViewCompat.getMinimumHeight(this.mRecyclerView);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:RecyclerView.java


注:本文中的android.support.v4.view.ViewCompat.getMinimumHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。