private static boolean isPassword(TextView view) { int inputType = view.getInputType(); if (inputType == InputType.TYPE_TEXT_VARIATION_PASSWORD) { return true; } TransformationMethod method = view.getTransformationMethod(); return method instanceof PasswordTransformationMethod; }
private static int getMaxLines(TextView view) { int maxLines = -1; // No limit (Integer.MAX_VALUE also means no limit) TransformationMethod method = view.getTransformationMethod(); if (method != null && method instanceof SingleLineTransformationMethod) { maxLines = 1; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // setMaxLines() and getMaxLines() are only available on android-16+ maxLines = view.getMaxLines(); } return maxLines; }
@Test public void shouldNotHaveTransformationMethodByDefault() { assertThat(textView.getTransformationMethod()).isNull(); }
TransformationMethod method = view.getTransformationMethod(); if (method != null) { text = method.getTransformation(text, view);
@Test public void shouldAllowSettingATransformationMethod() { textView.setTransformationMethod(PasswordTransformationMethod.getInstance()); assertThat(textView.getTransformationMethod()).isInstanceOf(PasswordTransformationMethod.class); }
/** * Get the visibility of this view. */ private boolean getPassWordVisibility() { return mViewArr[0].getTransformationMethod() == null; }
private static int getMaxLines(TextView view) { int maxLines = -1; // No limit (Integer.MAX_VALUE also means no limit) TransformationMethod method = view.getTransformationMethod(); if (method != null && method instanceof SingleLineTransformationMethod) { maxLines = 1; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // setMaxLines() and getMaxLines() are only available on android-16+ maxLines = view.getMaxLines(); } return maxLines; }
public static float calculateTextWidth(TextView textView, String text) { final Paint p = new Paint(); p.setTextSize(textView.getTextSize()); String output = text; TransformationMethod method = textView.getTransformationMethod(); if (method != null) { output = (String) method.getTransformation(text, textView); } return p.measureText(output); }
if (view.getTransformationMethod() instanceof PasswordTransformationMethod) { return false;
TransformationMethod method = view.getTransformationMethod(); if (method != null) { text = method.getTransformation(text, view);
e.printStackTrace(); data.put("TransformationMethod", String.valueOf(tv.getTransformationMethod())); data.put("Typeface", String.valueOf(tv.getTypeface())); data.put("Urls", tv.getUrls() != null ? Arrays.toString(tv.getUrls()) : "null");