Example usage for com.facebook.react.uimanager ViewDefaults FONT_SIZE_SP

List of usage examples for com.facebook.react.uimanager ViewDefaults FONT_SIZE_SP

Introduction

In this page you can find the example usage for com.facebook.react.uimanager ViewDefaults FONT_SIZE_SP.

Prototype

float FONT_SIZE_SP

To view the source code for com.facebook.react.uimanager ViewDefaults FONT_SIZE_SP.

Click Source Link

Usage

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;//  w  ww .  j  a va2  s  .  c o 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();
}