当前位置: 首页>>代码示例>>Java>>正文


Java TransformationMethod类代码示例

本文整理汇总了Java中android.text.method.TransformationMethod的典型用法代码示例。如果您正苦于以下问题:Java TransformationMethod类的具体用法?Java TransformationMethod怎么用?Java TransformationMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransformationMethod类属于android.text.method包,在下文中一共展示了TransformationMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMaxLines

import android.text.method.TransformationMethod; //导入依赖的package包/类
private static int getMaxLines(AppCompatTextView 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;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:18,代码来源:AutofitHelper.java

示例2: onCheckedChanged

import android.text.method.TransformationMethod; //导入依赖的package包/类
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
    final TransformationMethod transformationMethod = isChecked ? null : PasswordTransformationMethod.getInstance();

    for (final EditText passwordView : passwordViews)
        passwordView.setTransformationMethod(transformationMethod);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:8,代码来源:ShowPasswordCheckListener.java

示例3: setTransformationMethod

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Sets the transformation that is applied to the text that this
 * TextView is displaying.
 *
 * @attr ref android.R.styleable#TextView_password
 * @attr ref android.R.styleable#TextView_singleLine
 */
public final void setTransformationMethod(TransformationMethod method) {
    if (method == mTransformation) {
        // Avoid the setText() below if the transformation is
        // the same.
        return;
    }
    if (mTransformation != null) {
        if (mText instanceof Spannable) {
            ((Spannable) mText).removeSpan(mTransformation);
        }
    }

    mTransformation = method;

    setText(mText);
}
 
开发者ID:jiro-aqua,项目名称:JotaTextEditor,代码行数:24,代码来源:TextView.java

示例4: getMaxLines

import android.text.method.TransformationMethod; //导入依赖的package包/类
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;
}
 
开发者ID:victorminerva,项目名称:AutoResizeEditText,代码行数:14,代码来源:AutofitHelper.java

示例5: getMaxLines

import android.text.method.TransformationMethod; //导入依赖的package包/类
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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:15,代码来源:AutofitHelper.java

示例6: isPasswordToggledVisible

import android.text.method.TransformationMethod; //导入依赖的package包/类
static ViewAssertion isPasswordToggledVisible(final boolean isToggledVisible) {
  return new ViewAssertion() {
    @Override
    public void check(View view, NoMatchingViewException noViewFoundException) {
      assertTrue(view instanceof TextInputLayout);
      EditText editText = ((TextInputLayout) view).getEditText();
      TransformationMethod transformationMethod = editText.getTransformationMethod();
      if (isToggledVisible) {
        assertNull(transformationMethod);
      } else {
        assertEquals(PasswordTransformationMethod.getInstance(), transformationMethod);
      }
    }
  };
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:16,代码来源:TextInputLayoutTest.java

示例7: getTranformedText

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Method that catch the text transformation (e.g. uppercase tranformation)
 * and return the transformed text
 * @param text the text to be transformed
 * @return transformed text
 */
private String getTranformedText(String text) {
    // Check if text has undergone transformation
    TransformationMethod transformationMethod = getTransformationMethod();
    if (transformationMethod != null) {
        // Get the tranformation
        text = transformationMethod.getTransformation(text, this).toString();
    }

    return text;
}
 
开发者ID:Gamabunta94,项目名称:AVTextView,代码行数:17,代码来源:AVTextView.java

示例8: refitText

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Re size the font so the specified text fits in the text box assuming the text box is the
 * specified width.
 */
private void refitText() {
    CharSequence text = getText();

    if (TextUtils.isEmpty(text)) {
        return;
    }

    TransformationMethod method = getTransformationMethod();
    if (method != null) {
        text = method.getTransformation(text, this);
    }
    int targetWidth = getWidth() - getPaddingLeft() - getPaddingRight();
    if (targetWidth > 0) {
        float high = 100;
        float low = 0;

        mPaint.set(getPaint());
        mPaint.setTextSize(getTextSize());
        float letterSpacing = getLetterSpacing(text, mPaint, targetWidth, low, high,
                mPrecision);
        mPaint.setLetterSpacing(letterSpacing);
        calculateSections(text);

        super.setLetterSpacing(letterSpacing);
    }
}
 
开发者ID:talentlo,项目名称:Trebuchet,代码行数:31,代码来源:AutoExpandTextView.java

示例9: onCheckedChanged

import android.text.method.TransformationMethod; //导入依赖的package包/类
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked)
{
    final TransformationMethod transformationMethod = isChecked ? null : PasswordTransformationMethod.getInstance();

    for (final EditText passwordView : passwordViews)
        passwordView.setTransformationMethod(transformationMethod);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:9,代码来源:ShowPasswordCheckListener.java

示例10: MaterialAutoCompleteTextView

import android.text.method.TransformationMethod; //导入依赖的package包/类
public MaterialAutoCompleteTextView(Context context, AttributeSet attrs, int style) {
    super(context, attrs, style);

    setFocusable(true);
    setFocusableInTouchMode(true);
    setClickable(true);

    floatingLabelTextSize = getResources().getDimensionPixelSize(R.dimen.floating_label_text_size);
    innerComponentsSpacing = getResources().getDimensionPixelSize(R.dimen.inner_components_spacing);
    bottomEllipsisSize = getResources().getDimensionPixelSize(R.dimen.bottom_ellipsis_height);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialEditText);
    baseColor = typedArray.getColor(R.styleable.MaterialEditText_baseColor, Color.BLACK);
    ColorStateList colorStateList = new ColorStateList(new int[][]{new int[]{android.R.attr.state_enabled}, EMPTY_STATE_SET}, new int[]{baseColor & 0x00ffffff | 0xdf000000, baseColor & 0x00ffffff | 0x44000000});
    setTextColor(colorStateList);

    primaryColor = typedArray.getColor(R.styleable.MaterialEditText_primaryColor, baseColor);
    setFloatingLabelInternal(typedArray.getInt(R.styleable.MaterialEditText_floatingLabel, 0));
    errorColor = typedArray.getColor(R.styleable.MaterialEditText_errorColor, Color.parseColor("#e7492E"));
    maxCharacters = typedArray.getInt(R.styleable.MaterialEditText_maxCharacters, 0);
    singleLineEllipsis = typedArray.getBoolean(R.styleable.MaterialEditText_singleLineEllipsis, false);
    typedArray.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(null);
    } else {
        setBackgroundDrawable(null);
    }
    if (singleLineEllipsis) {
        TransformationMethod transformationMethod = getTransformationMethod();
        setSingleLine();
        setTransformationMethod(transformationMethod);
    }
    initPadding();
    initText();
    initFloatingLabel();
}
 
开发者ID:championswimmer,项目名称:Bookd_Android_App,代码行数:38,代码来源:MaterialAutoCompleteTextView.java

示例11: MaterialEditText

import android.text.method.TransformationMethod; //导入依赖的package包/类
public MaterialEditText(Context context, AttributeSet attrs, int style) {
    super(context, attrs, style);

    setFocusable(true);
    setFocusableInTouchMode(true);
    setClickable(true);

    floatingLabelTextSize = getResources().getDimensionPixelSize(R.dimen.floating_label_text_size);
    innerComponentsSpacing = getResources().getDimensionPixelSize(R.dimen.inner_components_spacing);
    bottomEllipsisSize = getResources().getDimensionPixelSize(R.dimen.bottom_ellipsis_height);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialEditText);
    baseColor = typedArray.getColor(R.styleable.MaterialEditText_baseColor, Color.BLACK);
    ColorStateList colorStateList = new ColorStateList(new int[][]{new int[]{android.R.attr.state_enabled}, EMPTY_STATE_SET}, new int[]{baseColor & 0x00ffffff | 0xdf000000, baseColor & 0x00ffffff | 0x44000000});
    setTextColor(colorStateList);

    primaryColor = typedArray.getColor(R.styleable.MaterialEditText_primaryColor, baseColor);
    setFloatingLabelInternal(typedArray.getInt(R.styleable.MaterialEditText_floatingLabel, 0));
    errorColor = typedArray.getColor(R.styleable.MaterialEditText_errorColor, R.styleable.MaterialEditText_BaseErrorColor);
    maxCharacters = typedArray.getInt(R.styleable.MaterialEditText_maxCharacters, 0);
    singleLineEllipsis = typedArray.getBoolean(R.styleable.MaterialEditText_singleLineEllipsis, false);
    regularExpression = typedArray.getString(R.styleable.MaterialEditText_regexExpression);
    regexErrorText = typedArray.getString(R.styleable.MaterialEditText_regexErrorText);
    regexText = typedArray.getString(R.styleable.MaterialEditText_regexText);
    typedArray.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(null);
    } else {
        setBackgroundDrawable(null);
    }
    if (singleLineEllipsis) {
        TransformationMethod transformationMethod = getTransformationMethod();
        setSingleLine();
        setTransformationMethod(transformationMethod);
    }
    initPadding();
    initText();
    initFloatingLabel();
}
 
开发者ID:championswimmer,项目名称:Bookd_Android_App,代码行数:41,代码来源:MaterialEditText.java

示例12: setTransformationMethod

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Sets the transformation that is applied to the text that this
 * TextView is displaying.
 *
 * @attr ref android.R.styleable#TextView_password
 * @attr ref android.R.styleable#TextView_singleLine
 */
public final void setTransformationMethod(TransformationMethod method) {
    if (method == mTransformation) {
        // Avoid the setText() below if the transformation is
        // the same.
        return;
    }
    if (mTransformation != null) {
        if (mText instanceof Spannable) {
            ((Spannable) mText).removeSpan(mTransformation);
        }
    }

    mTransformation = method;

    if (method instanceof TransformationMethod2) {
        TransformationMethod2 method2 = (TransformationMethod2) method;
        mAllowTransformationLengthChange = !isTextSelectable() && !(mText instanceof Editable);
        method2.setLengthChangesAllowed(mAllowTransformationLengthChange);
    } else {
        mAllowTransformationLengthChange = false;
    }

    setText(mText);

    if (hasPasswordTransformationMethod()) {
        notifyViewAccessibilityStateChangedIfNeeded(
                AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
    }
}
 
开发者ID:AungThiha,项目名称:Tada,代码行数:37,代码来源:TextView.java

示例13: autofit

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
    * Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
    */
   private static void autofit(AppCompatTextView view, TextPaint paint, float minTextSize, float maxTextSize,
							int maxLines, float precision)
{
       if (maxLines <= 0 || maxLines == Integer.MAX_VALUE)
	{
           // Don't auto-size since there's no limit on lines.
           return;
       }

       int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
       if (targetWidth <= 0)
	{
           return;
       }

       CharSequence text = view.getText();
       TransformationMethod method = view.getTransformationMethod();
       if (method != null)
	{
           text = method.getTransformation(text, view);
       }

       Context context = view.getContext();
       Resources r = Resources.getSystem();
       DisplayMetrics displayMetrics;

       float size = maxTextSize;
       float high = size;
       float low = 0;

       if (context != null)
	{
           r = context.getResources();
       }
       displayMetrics = r.getDisplayMetrics();

       paint.set(view.getPaint());
       paint.setTextSize(size);

       if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
		|| getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines)
	{
           size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision,
								  displayMetrics);
       }

       if (size < minTextSize)
	{
           size = minTextSize;
       }

       view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:57,代码来源:AutofitHelper.java

示例14: autofit

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
 */
private static void autofit(TextView view, TextPaint paint, float minTextSize, float maxTextSize,
                            int maxLines, float precision) {
    if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
        // Don't auto-size since there's no limit on lines.
        return;
    }

    int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
    if (targetWidth <= 0) {
        return;
    }

    CharSequence text = view.getText();
    TransformationMethod method = view.getTransformationMethod();
    if (method != null) {
        text = method.getTransformation(text, view);
    }

    Context context = view.getContext();
    Resources r = Resources.getSystem();
    DisplayMetrics displayMetrics;

    float size = maxTextSize;
    float high = size;
    float low = 0;

    if (context != null) {
        r = context.getResources();
    }
    displayMetrics = r.getDisplayMetrics();

    paint.set(view.getPaint());
    paint.setTextSize(size);

    if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
            || getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
        size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision,
                displayMetrics);
    }

    if (size < minTextSize) {
        size = minTextSize;
    }

    view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
 
开发者ID:victorminerva,项目名称:AutoResizeEditText,代码行数:50,代码来源:AutofitHelper.java

示例15: adjustTextSize

import android.text.method.TransformationMethod; //导入依赖的package包/类
/**
 * Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
 */
private static void adjustTextSize(TextView view, TextPaint paint, float minTextSize, float maxTextSize, int maxLines, float precision) {
    if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
        // Don't auto-size since there's no limit on lines.
        return;
    }

    int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
    if (targetWidth <= 0) {
        return;
    }

    CharSequence text = view.getText();
    TransformationMethod method = view.getTransformationMethod();
    if (method != null) {
        text = method.getTransformation(text, view);
    }

    Context context = view.getContext();
    Resources r = Resources.getSystem();
    DisplayMetrics displayMetrics;

    float size = maxTextSize;
    float high = size;
    float low = 0;

    if (context != null) {
        r = context.getResources();
    }
    displayMetrics = r.getDisplayMetrics();

    paint.set(view.getPaint());
    paint.setTextSize(size);

    if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
            || getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
        size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision, displayMetrics);
    }

    if (size < minTextSize) {
        size = minTextSize;
    }

    view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:48,代码来源:TextUtil.java


注:本文中的android.text.method.TransformationMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。