List of usage examples for com.facebook.react.uimanager PixelUtil toPixelFromSP
public static float toPixelFromSP(double value)
From source file:fr.bamlab.textinput.ReactTextInputManager.java
License:Open Source License
@Override public ReactEditText createViewInstance(ThemedReactContext context) { ReactEditText editText = new ReactEditText(context); int inputType = editText.getInputType(); editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE)); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP))); return editText; }
From source file:fr.bamlab.textinput.ReactTextInputManager.java
License:Open Source License
@ReactProp(name = ViewProps.FONT_SIZE, defaultFloat = ViewDefaults.FONT_SIZE_SP) public void setFontSize(ReactEditText view, float fontSize) { view.setTextSize(TypedValue.COMPLEX_UNIT_PX, (int) Math.ceil(PixelUtil.toPixelFromSP(fontSize))); }
From source file:fr.bamlab.textinput.ReactTextInputShadowNode.java
License:Open Source License
@Override public void measure(CSSNode node, float width, float height, MeasureOutput measureOutput) { // measure() should never be called before setThemedContext() EditText editText = Assertions.assertNotNull(mEditText); measureOutput.width = width;/*from w ww .j a v a 2s.co m*/ 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(MEASURE_SPEC, MEASURE_SPEC); measureOutput.height = editText.getMeasuredHeight(); }