MaterialEditText.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:Studddinv2_android 作者:
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();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号