當前位置: 首頁>>代碼示例>>Java>>正文


Java CSSMeasureMode類代碼示例

本文整理匯總了Java中com.facebook.csslayout.CSSMeasureMode的典型用法代碼示例。如果您正苦於以下問題:Java CSSMeasureMode類的具體用法?Java CSSMeasureMode怎麽用?Java CSSMeasureMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CSSMeasureMode類屬於com.facebook.csslayout包,在下文中一共展示了CSSMeasureMode類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  if (!mMeasured) {
    // Create a switch with the default config and measure it; since we don't (currently)
    // support setting custom switch text, this is fine, as all switches will measure the same
    // on a specific device/theme/locale combination.
    ReactSwitch reactSwitch = new ReactSwitch(getThemedContext());
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSwitch.measure(spec, spec);
    mWidth = reactSwitch.getMeasuredWidth();
    mHeight = reactSwitch.getMeasuredHeight();
    mMeasured = true;
  }
  measureOutput.width = mWidth;
  measureOutput.height = mHeight;
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:25,代碼來源:ReactSwitchManager.java

示例2: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
  if (!mMeasured.contains(style)) {
    ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    progressBar.measure(spec, spec);
    mHeight.put(style, progressBar.getMeasuredHeight());
    mWidth.put(style, progressBar.getMeasuredWidth());
    mMeasured.add(style);
  }

  measureOutput.height = mHeight.get(style);
  measureOutput.width = mWidth.get(style);
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:24,代碼來源:ProgressBarShadowNode.java

示例3: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  if (!mMeasured) {
    SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSlider.measure(spec, spec);
    mWidth = reactSlider.getMeasuredWidth();
    mHeight = reactSlider.getMeasuredHeight();
    mMeasured = true;
  }
  measureOutput.width = mWidth;
  measureOutput.height = mHeight;
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:22,代碼來源:ReactSliderManager.java

示例4: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  if (!mMeasured) {
    // Create a switch with the default config and measure it; since we don't (currently)
    // support setting custom switch text, this is fine, as all switches will measure the same
    // on a specific device/theme/locale combination.
    ReactSwitch reactSwitch = new ReactSwitch(getThemedContext());
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSwitch.measure(spec, spec);
    mWidth = reactSwitch.getMeasuredWidth();
    mHeight = reactSwitch.getMeasuredHeight();
    mMeasured = true;
  }
  measureOutput.width = mWidth;
  measureOutput.height = mHeight;
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:25,代碼來源:ReactSwitchManager.java

示例5: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
  if (!mMeasured.contains(style)) {
    ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    progressBar.measure(spec, spec);
    mHeight.put(style, progressBar.getMeasuredHeight());
    mWidth.put(style, progressBar.getMeasuredWidth());
    mMeasured.add(style);
  }

  measureOutput.height = mHeight.get(style);
  measureOutput.width = mWidth.get(style);
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:24,代碼來源:ProgressBarShadowNode.java

示例6: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  if (!mMeasured) {
    SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSlider.measure(spec, spec);
    mWidth = reactSlider.getMeasuredWidth();
    mHeight = reactSlider.getMeasuredHeight();
    mMeasured = true;
  }
  measureOutput.width = mWidth;
  measureOutput.height = mHeight;
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:22,代碼來源:ReactSliderManager.java

示例7: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  measureOutput.width = widthMode == CSSMeasureMode.UNDEFINED ? CSSConstants.UNDEFINED : width;
  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      mFontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
  mComputedPadding = spacingToFloatArray(getPadding());
  editText.setPadding(
      (int) Math.ceil(getPadding().get(Spacing.LEFT)),
      (int) Math.ceil(getPadding().get(Spacing.TOP)),
      (int) Math.ceil(getPadding().get(Spacing.RIGHT)),
      (int) Math.ceil(getPadding().get(Spacing.BOTTOM)));

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  editText.measure(0 /* unspecified */, 0 /* unspecified */);
  measureOutput.height = editText.getMeasuredHeight();
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:31,代碼來源:ReactTextInputShadowNode.java

示例8: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  throw new IllegalStateException("SurfaceView should have explicit width and height set");
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:11,代碼來源:ARTSurfaceViewManager.java

示例9: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      mFontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
  mComputedPadding = new float[] {
      getPadding(Spacing.START),
      getPadding(Spacing.TOP),
      getPadding(Spacing.END),
      getPadding(Spacing.BOTTOM),
  };
  editText.setPadding(
      (int) Math.floor(getPadding(Spacing.START)),
      (int) Math.floor(getPadding(Spacing.TOP)),
      (int) Math.floor(getPadding(Spacing.END)),
      (int) Math.floor(getPadding(Spacing.BOTTOM)));

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));
  measureOutput.width = editText.getMeasuredWidth();
  measureOutput.height = editText.getMeasuredHeight();
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:38,代碼來源:ReactTextInputShadowNode.java

示例10: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  throw new IllegalStateException("SurfaceView should have explicit width and height set");
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:11,代碼來源:ARTSurfaceViewManager.java

示例11: getMeasureSpec

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
public static int getMeasureSpec(float size, CSSMeasureMode mode) {
  if (mode == CSSMeasureMode.EXACTLY) {
    return View.MeasureSpec.makeMeasureSpec((int) size, View.MeasureSpec.EXACTLY);
  } else if (mode == CSSMeasureMode.AT_MOST) {
    return View.MeasureSpec.makeMeasureSpec((int) size, View.MeasureSpec.AT_MOST);
  } else {
    return View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
  }
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:10,代碼來源:MeasureUtil.java

示例12: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public long measure(CSSNodeAPI node,
                    float width,
                    CSSMeasureMode widthMode,
                    float height,
                    CSSMeasureMode heightMode) {
    if(show) {
        int calcHeight = keys.size() * (RnckKeyboard.DEFAULT_KEY_HEIGHT + RnckKeyboard.DEFAULT_VERTICAL_GAP);
        return MeasureOutput.make(width, calcHeight);
    } else {
        return MeasureOutput.make(0, 0);
    }
}
 
開發者ID:reneweb,項目名稱:rnck,代碼行數:14,代碼來源:RnckKeyboardManager.java

示例13: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNode node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  // TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic)
  ReactTextShadowNode reactCSSNode = (ReactTextShadowNode) node;
  TextPaint textPaint = sTextPaintInstance;
  Layout layout;
  Spanned text = Assertions.assertNotNull(
      reactCSSNode.mPreparedSpannableText,
      "Spannable element has not been prepared in onBeforeLayout");
  BoringLayout.Metrics boring = BoringLayout.isBoring(text, textPaint);
  float desiredWidth = boring == null ?
      Layout.getDesiredWidth(text, textPaint) : Float.NaN;

  // technically, width should never be negative, but there is currently a bug in
  boolean unconstrainedWidth = widthMode == CSSMeasureMode.UNDEFINED || width < 0;

  if (boring == null &&
      (unconstrainedWidth ||
          (!CSSConstants.isUndefined(desiredWidth) && desiredWidth <= width))) {
    // Is used when the width is not known and the text is not boring, ie. if it contains
    // unicode characters.
    layout = new StaticLayout(
        text,
        textPaint,
        (int) Math.ceil(desiredWidth),
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        true);
  } else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
    // Is used for single-line, boring text when the width is either unknown or bigger
    // than the width of the text.
    layout = BoringLayout.make(
        text,
        textPaint,
        boring.width,
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        boring,
        true);
  } else {
    // Is used for multiline, boring text and the width is known.
    layout = new StaticLayout(
        text,
        textPaint,
        (int) width,
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        true);
  }

  measureOutput.height = layout.getHeight();
  measureOutput.width = layout.getWidth();
  if (reactCSSNode.mNumberOfLines != UNSET &&
      reactCSSNode.mNumberOfLines < layout.getLineCount()) {
    measureOutput.height = layout.getLineBottom(reactCSSNode.mNumberOfLines - 1);
  }
  if (reactCSSNode.mLineHeight != UNSET) {
    int lines = reactCSSNode.mNumberOfLines != UNSET
        ? Math.min(reactCSSNode.mNumberOfLines, layout.getLineCount())
        : layout.getLineCount();
    float lineHeight = PixelUtil.toPixelFromSP(reactCSSNode.mLineHeight);
    measureOutput.height = lineHeight * lines;
  }
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:74,代碼來源:ReactTextShadowNode.java

示例14: measure

import com.facebook.csslayout.CSSMeasureMode; //導入依賴的package包/類
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  // TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic)
  ReactTextShadowNode reactCSSNode = (ReactTextShadowNode) node;
  TextPaint textPaint = sTextPaintInstance;
  Layout layout;
  Spanned text = Assertions.assertNotNull(
      reactCSSNode.mPreparedSpannableText,
      "Spannable element has not been prepared in onBeforeLayout");
  BoringLayout.Metrics boring = BoringLayout.isBoring(text, textPaint);
  float desiredWidth = boring == null ?
      Layout.getDesiredWidth(text, textPaint) : Float.NaN;

  // technically, width should never be negative, but there is currently a bug in
  boolean unconstrainedWidth = widthMode == CSSMeasureMode.UNDEFINED || width < 0;

  if (boring == null &&
      (unconstrainedWidth ||
          (!CSSConstants.isUndefined(desiredWidth) && desiredWidth <= width))) {
    // Is used when the width is not known and the text is not boring, ie. if it contains
    // unicode characters.
    layout = new StaticLayout(
        text,
        textPaint,
        (int) Math.ceil(desiredWidth),
        Layout.Alignment.ALIGN_NORMAL,
        1.f,
        0.f,
        true);
  } else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
    // Is used for single-line, boring text when the width is either unknown or bigger
    // than the width of the text.
    layout = BoringLayout.make(
        text,
        textPaint,
        boring.width,
        Layout.Alignment.ALIGN_NORMAL,
        1.f,
        0.f,
        boring,
        true);
  } else {
    // Is used for multiline, boring text and the width is known.
    layout = new StaticLayout(
        text,
        textPaint,
        (int) width,
        Layout.Alignment.ALIGN_NORMAL,
        1.f,
        0.f,
        true);
  }

  measureOutput.height = layout.getHeight();
  measureOutput.width = layout.getWidth();
  if (reactCSSNode.mNumberOfLines != UNSET &&
      reactCSSNode.mNumberOfLines < layout.getLineCount()) {
    measureOutput.height = layout.getLineBottom(reactCSSNode.mNumberOfLines - 1);
  }
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:67,代碼來源:ReactTextShadowNode.java


注:本文中的com.facebook.csslayout.CSSMeasureMode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。