Java Code Examples for android.widget.EditText#setBreakStrategy()

The following examples show how to use android.widget.EditText#setBreakStrategy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactTextInputLocalData.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void apply(EditText editText) {
  editText.setText(mText);
  editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
  editText.setMinLines(mMinLines);
  editText.setMaxLines(mMaxLines);
  editText.setInputType(mInputType);
  editText.setHint(mPlaceholder);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    editText.setBreakStrategy(mBreakStrategy);
  }
}
 
Example 2
Source File: ReactTextInputShadowNode.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mDummyEditText);

  if (mLocalData != null) {
    mLocalData.apply(editText);
  } else {
    editText.setTextSize(
        TypedValue.COMPLEX_UNIT_PX,
        mFontSize == UNSET ?
            (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
        editText.getBreakStrategy() != mTextBreakStrategy) {
      editText.setBreakStrategy(mTextBreakStrategy);
    }
  }

   // make sure the placeholder content is also being measured
   editText.setHint(getPlaceholder());
   editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));

  return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}