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


Java View.resolveSize方法代码示例

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


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

示例1: onMeasure

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = View.resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec);
    int height = View.resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec);

    int childWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.UNSPECIFIED);
    int childHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED);

    int count = this.getChildCount();
    for (int i = 0; i < count; i++) {
        getChildAt(i).measure(childWidthSpec, childHeightSpec);
    }

    height = mChildrenMeasure.measureByTotalWidth(width).getTotalHeight();
    if (mChildrenMeasure.hasPreLayoutView() && getMeasuredHeight() > height) {
        height = getMeasuredHeight();
    }
    this.setMeasuredDimension(width, height);
}
 
开发者ID:sjnyag,项目名称:AnimationWrapLayout,代码行数:20,代码来源:AnimationWrapLayout.java

示例2: updateMeasureSpec

import android.view.View; //导入方法依赖的package包/类
/**
 * Updates the given measure spec with respect to the aspect ratio.
 *
 * <p>Note: Measure spec is not changed if the aspect ratio is not greater than zero or if
 * layoutParams is null.
 *
 * <p>Measure spec of the layout dimension (width or height) specified as "0dp" is updated
 * to match the measure spec of the other dimension adjusted by the aspect ratio. Exactly one
 * layout dimension should be specified as "0dp".
 *
 * <p>Padding is taken into account so that the aspect ratio refers to the content without
 * padding: {@code aspectRatio == (viewWidth - widthPadding) / (viewHeight - heightPadding)}
 *
 * <p>Updated measure spec respects the parent's constraints. I.e. measure spec is not changed
 * if the parent has specified mode {@code EXACTLY}, and it doesn't exceed measure size if parent
 * has specified mode {@code AT_MOST}.
 *
 * @param spec in/out measure spec to be updated
 * @param aspectRatio desired aspect ratio
 * @param layoutParams view's layout params
 * @param widthPadding view's left + right padding
 * @param heightPadding view's top + bottom padding
 */
public static void updateMeasureSpec(
    Spec spec,
    float aspectRatio,
    @Nullable ViewGroup.LayoutParams layoutParams,
    int widthPadding,
    int heightPadding) {
  if (aspectRatio <= 0 || layoutParams == null) {
    return;
  }
  if (shouldAdjust(layoutParams.height)) {
    int widthSpecSize = View.MeasureSpec.getSize(spec.width);
    int desiredHeight = (int) ((widthSpecSize - widthPadding) / aspectRatio + heightPadding);
    int resolvedHeight = View.resolveSize(desiredHeight, spec.height);
    spec.height = View.MeasureSpec.makeMeasureSpec(resolvedHeight, View.MeasureSpec.EXACTLY);
  } else if (shouldAdjust(layoutParams.width)) {
    int heightSpecSize = View.MeasureSpec.getSize(spec.height);
    int desiredWidth = (int) ((heightSpecSize - heightPadding) * aspectRatio + widthPadding);
    int resolvedWidth = View.resolveSize(desiredWidth, spec.width);
    spec.width = View.MeasureSpec.makeMeasureSpec(resolvedWidth, View.MeasureSpec.EXACTLY);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:45,代码来源:AspectRatioMeasure.java

示例3: resolveSizeAndState

import android.view.View; //导入方法依赖的package包/类
@Override
public int resolveSizeAndState(int size, int measureSpec, int state) {
    return View.resolveSize(size, measureSpec);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:5,代码来源:Utility4.java

示例4: updateMeasureSpec

import android.view.View; //导入方法依赖的package包/类
/**
 * Updates the given measure spec with respect to the aspect ratio.
 *
 * <p>Note: Measure spec is not changed if the aspect ratio is not greater than zero or if
 * layoutParams is null.
 *
 * <p>Measure spec of the layout dimension (width or height) specified as "0dp" is updated
 * to match the measure spec of the other dimension adjusted by the aspect ratio. Exactly one
 * layout dimension should be specified as "0dp".
 *
 * <p>Padding is taken into account so that the aspect ratio refers to the content without
 * padding: {@code aspectRatio == (viewWidth - widthPadding) / (viewHeight - heightPadding)}
 *
 * <p>Updated measure spec respects the parent's constraints. I.e. measure spec is not changed
 * if the parent has specified mode {@code EXACTLY}, and it doesn't exceed measure size if parent
 * has specified mode {@code AT_MOST}.
 *
 * @param spec in/out measure spec to be updated
 * @param aspectRatio desired aspect ratio
 * @param layoutParams view's layout params
 * @param widthPadding view's left + right padding
 * @param heightPadding view's top + bottom padding
 */
public static void updateMeasureSpec(
        Spec spec,
        float aspectRatio,
        @Nullable ViewGroup.LayoutParams layoutParams,
        int widthPadding,
        int heightPadding) {
    if (aspectRatio <= 0 || layoutParams == null) {
        return;
    }
    if (shouldAdjust(layoutParams.height)) {
        int widthSpecSize = View.MeasureSpec.getSize(spec.width);
        int desiredHeight = (int) ((widthSpecSize - widthPadding) / aspectRatio + heightPadding);
        int resolvedHeight = View.resolveSize(desiredHeight, spec.height);
        spec.height = View.MeasureSpec.makeMeasureSpec(resolvedHeight, View.MeasureSpec.EXACTLY);
    } else if (shouldAdjust(layoutParams.width)) {
        int heightSpecSize = View.MeasureSpec.getSize(spec.height);
        int desiredWidth = (int) ((heightSpecSize - heightPadding) * aspectRatio + widthPadding);
        int resolvedWidth = View.resolveSize(desiredWidth, spec.width);
        spec.width = View.MeasureSpec.makeMeasureSpec(resolvedWidth, View.MeasureSpec.EXACTLY);
    }
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:45,代码来源:PercentAspectRatioMeasure.java

示例5: resolveSizeAndState

import android.view.View; //导入方法依赖的package包/类
public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
    return View.resolveSize(size, measureSpec);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:ViewCompat.java


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