android.widget.EditText#setBackground ( )源码实例Demo

下面列出了android.widget.EditText#setBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: YCCustomText   文件: HyperTextEditor.java
/**
 * 添加生成文本输入框
 * @param hint								内容
 * @param paddingTop						到顶部高度
 * @return
 */
private EditText createEditText(String hint, int paddingTop) {
	EditText editText = new DeletableEditText(getContext());
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	editText.setLayoutParams(layoutParams);
	editText.setTextSize(16);
	editText.setTextColor(Color.parseColor("#616161"));
	editText.setCursorVisible(true);
	editText.setBackground(null);
	editText.setOnKeyListener(keyListener);
	editText.setOnFocusChangeListener(focusListener);
	editText.addTextChangedListener(textWatcher);
	editText.setTag(viewTagIndex++);
	editText.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
	editText.setHint(hint);
	editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
	editText.setTextColor(rtTextColor);
	editText.setHintTextColor(rtHintTextColor);
	editText.setLineSpacing(rtTextLineSpace, 1.0f);
	HyperLibUtils.setCursorDrawableColor(editText, cursorColor);
	return editText;
}
 
源代码2 项目: DebugRank   文件: CodeLineCellFactory.java
@Override
public View createCellEditor(GridPanel gridPanel, GridCellRange cellRange, Rect bounds)
{
    EditText editText = (EditText) super.createCellEditor(gridPanel, cellRange, bounds);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        editText.setBackground(null);
    }

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        editText.setBackgroundTintMode(PorterDuff.Mode.CLEAR);
    }

    editText.setBackgroundColor(ContextCompat.getColor(flexGrid.getContext(), R.color.colorTransparent));

    return editText;
}
 
private void setBg(EditText editText, boolean focus) {
    if (boxBgNormal != null && !focus) {
        editText.setBackground(boxBgNormal);
    } else if (boxBgFocus != null && focus) {
        editText.setBackground(boxBgFocus);
    }
}
 
源代码4 项目: nono-android   文件: PinViewBaseHelper.java
/**
 * Set a PinBox with all attributes
 *
 * @param editText to set attributes
 */
private void setStylePinBox(EditText editText) {
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)});

    if (mMaskPassword) {
        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
    else{
        editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }

    if (mNativePinBox) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            //noinspection deprecation
            editText.setBackgroundDrawable(new EditText(getContext()).getBackground());
        } else {
            editText.setBackground(new EditText(getContext()).getBackground());
        }
    } else {
        editText.setBackgroundResource(mCustomDrawablePinBox);
    }

    if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) {
        editText.setTextColor(mColorTextPinBoxes);
    }
    editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes));
}
 
源代码5 项目: PinView   文件: PinViewBaseHelper.java
/**
 * Set a PinBox with all attributes
 *
 * @param editText to set attributes
 */
private void setStylePinBox(EditText editText) {
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)});

    if (mMaskPassword) {
        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
    else{
        editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }

    if (mNativePinBox) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            //noinspection deprecation
            editText.setBackgroundDrawable(new EditText(getContext()).getBackground());
        } else {
            editText.setBackground(new EditText(getContext()).getBackground());
        }
    } else {
        editText.setBackgroundResource(mCustomDrawablePinBox);
    }

    if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) {
        editText.setTextColor(mColorTextPinBoxes);
    }
    editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes));
}