Example usage for android.content.res TypedArray getIndex

List of usage examples for android.content.res TypedArray getIndex

Introduction

In this page you can find the example usage for android.content.res TypedArray getIndex.

Prototype

public int getIndex(int at) 

Source Link

Document

Returns an index in the array that has data.

Usage

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

public AnyKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //creating the KeyDrawableStateProvider, as it suppose to be backward compatible
    int keyTypeFunctionAttrId = R.attr.key_type_function;
    int keyActionAttrId = R.attr.key_type_action;
    int keyActionTypeDoneAttrId = R.attr.action_done;
    int keyActionTypeSearchAttrId = R.attr.action_search;
    int keyActionTypeGoAttrId = R.attr.action_go;

    LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // int previewLayout = 0;
    mPreviewKeyTextSize = -1;/*from  w w w . java2 s.c om*/
    mPreviewLabelTextSize = -1;
    mPreviewKeyBackground = null;
    mPreviewKeyTextColor = 0xFFF;
    final int[] padding = new int[] { 0, 0, 0, 0 };

    KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(context.getApplicationContext());
    final int keyboardThemeStyleResId = getKeyboardStyleResId(theme);
    Log.d(TAG, "Will use keyboard theme " + theme.getName() + " id " + theme.getId() + " res "
            + keyboardThemeStyleResId);

    //creating a mapping from the remote Attribute IDs to my local attribute ID.
    //this is required in order to backward support any build-system (which may cause the attribute IDs to change)
    final SparseIntArray attributeIdMap = new SparseIntArray(R.styleable.AnyKeyboardViewTheme.length
            + R.styleable.AnyKeyboardViewIconsTheme.length + ACTION_KEY_TYPES.length + KEY_TYPES.length);

    final int[] remoteKeyboardThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable(
            R.styleable.AnyKeyboardViewTheme, context, theme.getPackageContext(), attributeIdMap);
    final int[] remoteKeyboardIconsThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable(
            R.styleable.AnyKeyboardViewIconsTheme, context, theme.getPackageContext(), attributeIdMap);

    HashSet<Integer> doneLocalAttributeIds = new HashSet<Integer>();
    TypedArray a = theme.getPackageContext().obtainStyledAttributes(keyboardThemeStyleResId,
            remoteKeyboardThemeStyleable);
    final int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        final int remoteIndex = a.getIndex(i);
        final int localAttrId = attributeIdMap.get(remoteKeyboardThemeStyleable[remoteIndex]);
        if (setValueFromTheme(a, padding, localAttrId, remoteIndex)) {
            doneLocalAttributeIds.add(localAttrId);
            if (localAttrId == R.attr.keyBackground) {
                //keyTypeFunctionAttrId and keyActionAttrId are remote
                final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable(KEY_TYPES,
                        context, theme.getPackageContext(), attributeIdMap);
                keyTypeFunctionAttrId = keyStateAttributes[0];
                keyActionAttrId = keyStateAttributes[1];
            }
        }
    }
    a.recycle();
    // taking icons
    int iconSetStyleRes = theme.getIconsThemeResId();
    Log.d(TAG, "Will use keyboard icons theme " + theme.getName() + " id " + theme.getId() + " res "
            + iconSetStyleRes);
    if (iconSetStyleRes != 0) {
        a = theme.getPackageContext().obtainStyledAttributes(iconSetStyleRes,
                remoteKeyboardIconsThemeStyleable);
        final int iconsCount = a.getIndexCount();
        for (int i = 0; i < iconsCount; i++) {
            final int remoteIndex = a.getIndex(i);
            final int localAttrId = attributeIdMap.get(remoteKeyboardIconsThemeStyleable[remoteIndex]);
            if (setKeyIconValueFromTheme(theme, a, localAttrId, remoteIndex)) {
                doneLocalAttributeIds.add(localAttrId);
                if (localAttrId == R.attr.iconKeyAction) {
                    //keyActionTypeDoneAttrId and keyActionTypeSearchAttrId and keyActionTypeGoAttrId are remote
                    final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable(
                            ACTION_KEY_TYPES, context, theme.getPackageContext(), attributeIdMap);
                    keyActionTypeDoneAttrId = keyStateAttributes[0];
                    keyActionTypeSearchAttrId = keyStateAttributes[1];
                    keyActionTypeGoAttrId = keyStateAttributes[2];
                }
            }
        }
        a.recycle();
    }
    // filling what's missing
    KeyboardTheme fallbackTheme = KeyboardThemeFactory.getFallbackTheme(context.getApplicationContext());
    final int keyboardFallbackThemeStyleResId = getKeyboardStyleResId(fallbackTheme);
    Log.d(TAG, "Will use keyboard fallback theme " + fallbackTheme.getName() + " id " + fallbackTheme.getId()
            + " res " + keyboardFallbackThemeStyleResId);
    a = fallbackTheme.getPackageContext().obtainStyledAttributes(keyboardFallbackThemeStyleResId,
            R.styleable.AnyKeyboardViewTheme);

    final int fallbackCount = a.getIndexCount();
    for (int i = 0; i < fallbackCount; i++) {
        final int index = a.getIndex(i);
        final int attrId = R.styleable.AnyKeyboardViewTheme[index];
        if (doneLocalAttributeIds.contains(attrId))
            continue;
        Log.d(TAG, "Falling back theme res ID " + index);
        setValueFromTheme(a, padding, attrId, index);
    }
    a.recycle();
    // taking missing icons
    int fallbackIconSetStyleId = fallbackTheme.getIconsThemeResId();
    Log.d(TAG, "Will use keyboard fallback icons theme " + fallbackTheme.getName() + " id "
            + fallbackTheme.getId() + " res " + fallbackIconSetStyleId);
    a = fallbackTheme.getPackageContext().obtainStyledAttributes(fallbackIconSetStyleId,
            R.styleable.AnyKeyboardViewIconsTheme);

    final int fallbackIconsCount = a.getIndexCount();
    for (int i = 0; i < fallbackIconsCount; i++) {
        final int index = a.getIndex(i);
        final int attrId = R.styleable.AnyKeyboardViewIconsTheme[index];
        if (doneLocalAttributeIds.contains(attrId))
            continue;
        Log.d(TAG, "Falling back icon res ID " + index);
        setKeyIconValueFromTheme(fallbackTheme, a, attrId, index);
    }
    a.recycle();
    //creating the key-drawable state provider, as we suppose to have the entire data now
    mDrawableStatesProvider = new KeyDrawableStateProvider(keyTypeFunctionAttrId, keyActionAttrId,
            keyActionTypeDoneAttrId, keyActionTypeSearchAttrId, keyActionTypeGoAttrId);

    // settings.
    // don't forget that there are TWO paddings, the theme's and the
    // background image's padding!
    Drawable keyboardBabground = super.getBackground();
    if (keyboardBabground != null) {
        Rect backgroundPadding = new Rect();
        keyboardBabground.getPadding(backgroundPadding);
        padding[0] += backgroundPadding.left;
        padding[1] += backgroundPadding.top;
        padding[2] += backgroundPadding.right;
        padding[3] += backgroundPadding.bottom;
    }
    super.setPadding(padding[0], padding[1], padding[2], padding[3]);

    final Resources res = getResources();
    mKeyboardDimens.setKeyboardMaxWidth(res.getDisplayMetrics().widthPixels - padding[0] - padding[2]);
    mPreviewPopup = new PopupWindow(context);
    if (mPreviewKeyTextSize > 0) {
        if (mPreviewLabelTextSize <= 0)
            mPreviewLabelTextSize = mPreviewKeyTextSize;
        mPreviewLayut = inflatePreviewWindowLayout(inflate);
        mPreviewText = (TextView) mPreviewLayut.findViewById(R.id.key_preview_text);
        mPreviewText.setTextColor(mPreviewKeyTextColor);
        mPreviewText.setTypeface(mKeyTextStyle);
        mPreviewIcon = (ImageView) mPreviewLayut.findViewById(R.id.key_preview_icon);
        mPreviewPopup.setBackgroundDrawable(mPreviewKeyBackground);
        mPreviewPopup.setContentView(mPreviewLayut);
        mShowPreview = mPreviewLayut != null;
    } else {
        mPreviewLayut = null;
        mPreviewText = null;
        mShowPreview = false;
    }
    mPreviewPopup.setTouchable(false);
    mPreviewPopup
            .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.KeyPreviewAnimation);
    mDelayBeforePreview = 0;
    mDelayAfterPreview = 10;

    mMiniKeyboardParent = this;
    mMiniKeyboardPopup = new PopupWindow(context.getApplicationContext());
    mMiniKeyboardPopup.setBackgroundDrawable(null);

    mMiniKeyboardPopup
            .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.MiniKeyboardAnimation);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(mKeyTextSize);
    mPaint.setTextAlign(Align.CENTER);
    mPaint.setAlpha(255);

    mKeyBackgroundPadding = new Rect(0, 0, 0, 0);
    mKeyBackground.getPadding(mKeyBackgroundPadding);

    reloadSwipeThresholdsSettings(res);

    mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance);

    AskOnGestureListener listener = new AskGestureEventsListener(this);

    mGestureDetector = AnyApplication.getDeviceSpecific().createGestureDetector(getContext(), listener);
    mGestureDetector.setIsLongpressEnabled(false);

    MultiTouchSupportLevel multiTouchSupportLevel = AnyApplication.getDeviceSpecific()
            .getMultiTouchSupportLevel(getContext());

    mHasDistinctMultitouch = multiTouchSupportLevel == MultiTouchSupportLevel.Distinct;

    mKeyRepeatInterval = 50;

    AnyApplication.getConfig().addChangedListener(this);
}

From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java

/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>//from   w w w .  jav a 2 s. co  m
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
@SuppressWarnings("ConstantConditions")
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    this.ensureRect();
    this.ensureDecorator();
    mDecorator.processAttributes(context, attrs, defStyleAttr, defStyleRes);
    this.mAnimations = Animations.get(this);

    /**
     * Process attributes.
     */
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_SeekBar, defStyleAttr,
            defStyleRes);
    if (typedArray != null) {
        final Rect indicatorTextPadding = new Rect();
        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_SeekBar_android_enabled) {
                setEnabled(typedArray.getBoolean(index, true));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscrete) {
                setDiscrete(typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscretePreviewEnabled) {
                setDiscretePreviewEnabled(typedArray.getBoolean(index, true));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIntervalRatio) {
                setDiscreteIntervalRatio(typedArray.getFloat(index, mDiscreteIntervalRatio));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicator) {
                setDiscreteIndicator(typedArray.getResourceId(index, 0));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextAppearance) {
                setDiscreteIndicatorTextAppearance(typedArray.getResourceId(index, 0));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextGravity) {
                setDiscreteIndicatorTextGravity(
                        typedArray.getInteger(index, DISCRETE_INDICATOR_TEXT_INFO.gravity));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextPaddingStart) {
                indicatorTextPadding.left = typedArray.getDimensionPixelSize(index, 0);
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextPaddingTop) {
                indicatorTextPadding.top = typedArray.getDimensionPixelSize(index, 0);
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextPaddingEnd) {
                indicatorTextPadding.right = typedArray.getDimensionPixelSize(index, 0);
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIndicatorTextPaddingBottom) {
                indicatorTextPadding.bottom = typedArray.getDimensionPixelSize(index, 0);
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIntervalTickMarkColor) {
                setDiscreteIntervalTickMarkColor(typedArray.getColorStateList(index));
            } else if (index == R.styleable.Ui_SeekBar_uiDiscreteIntervalTickMarkRadius) {
                setDiscreteIntervalTickMarkRadius(typedArray.getDimensionPixelSize(index, 0));
            }
        }
        setDiscreteIndicatorTextPadding(indicatorTextPadding.left, indicatorTextPadding.top,
                indicatorTextPadding.right, indicatorTextPadding.bottom);
        typedArray.recycle();
    }
    this.applyProgressTints();
    this.applyThumbTint();
}

From source file:com.ruesga.rview.widget.TagEditTextView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr) {
    mHandler = new Handler(mTagMessenger);
    mTriggerTagCreationThreshold = CREATE_CHIP_DEFAULT_DELAYED_TIMEOUT;

    Resources.Theme theme = ctx.getTheme();
    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TagEditTextView, defStyleAttr, 0);

    mReadOnly = a.getBoolean(R.styleable.TagEditTextView_readonly, false);
    mDefaultTagMode = TAG_MODE.HASH;//from w w  w. j av  a2  s  . c o  m

    // Create the internal EditText that holds the tag logic
    mTagEdit = mReadOnly ? new TagEditText(ctx, attrs, defStyleAttr) : new TagEditText(ctx, attrs);
    mTagEdit.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0));
    mTagEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mTagEdit.addTextChangedListener(mEditListener);
    mTagEdit.setTextIsSelectable(false);
    mTagEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mTagEdit.setOnFocusChangeListener((v, hasFocus) -> {
        // Remove any pending message
        mHandler.removeMessages(MESSAGE_CREATE_CHIP);
    });
    mTagEdit.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {

        }
    });
    addView(mTagEdit);

    // Configure the window mode for landscape orientation, to disallow hide the
    // EditText control, and show characters instead of chips
    int orientation = ctx.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (ctx instanceof Activity) {
            Window window = ((Activity) ctx).getWindow();
            if (window != null) {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
                mTagEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            }
        }
    }

    // Save the keyListener for later restore
    mEditModeKeyListener = mTagEdit.getKeyListener();

    // Initialize resources for chips
    mChipBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mChipFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mChipFgPaint.setTextSize(mTagEdit.getTextSize() * (mReadOnly ? 1 : 0.8f));
    if (CHIP_TYPEFACE != null) {
        mChipFgPaint.setTypeface(CHIP_TYPEFACE);
    }
    mChipFgPaint.setTextAlign(Paint.Align.LEFT);

    // Calculate the width area used to remove the tag in the chip
    mChipRemoveAreaWidth = (int) (mChipFgPaint.measureText(CHIP_REMOVE_TEXT) + 0.5f);

    if (ONE_PIXEL <= 0) {
        Resources res = getResources();
        ONE_PIXEL = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics());
    }

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.TagEditTextView_supportUserTags:
            setSupportsUserTags(a.getBoolean(attr, false));
            break;

        case R.styleable.TagEditTextView_chipBackgroundColor:
            mChipBackgroundColor = a.getColor(attr, mChipBackgroundColor);
            break;

        case R.styleable.TagEditTextView_chipTextColor:
            mChipFgPaint.setColor(a.getColor(attr, Color.WHITE));
            break;
        }
    }
    a.recycle();
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.EditText.java

@Override
protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super.applyStyle(context, attrs, defStyleAttr, defStyleRes);

    CharSequence text = mInputView == null ? null : mInputView.getText();
    removeAllViews();/*  w  ww.j  a  va 2  s . c  o  m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EditText, defStyleAttr, defStyleRes);

    int labelPadding = -1;
    int labelTextSize = -1;
    ColorStateList labelTextColor = null;
    int supportPadding = -1;
    int supportTextSize = -1;
    ColorStateList supportColors = null;
    ColorStateList supportErrorColors = null;
    String supportHelper = null;
    String supportError = null;
    ColorStateList dividerColors = null;
    ColorStateList dividerErrorColors = null;
    int dividerHeight = -1;
    int dividerPadding = -1;
    int dividerAnimDuration = -1;

    mAutoCompleteMode = a.getInteger(R.styleable.EditText_et_autoCompleteMode, mAutoCompleteMode);
    if (needCreateInputView(mAutoCompleteMode)) {
        switch (mAutoCompleteMode) {
        case AUTOCOMPLETE_MODE_SINGLE:
            mInputView = new InternalAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        case AUTOCOMPLETE_MODE_MULTI:
            mInputView = new InternalMultiAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        default:
            mInputView = new InternalEditText(context, attrs, defStyleAttr);
            break;
        }
        ViewUtil.applyFont(mInputView, attrs, defStyleAttr, defStyleRes);
        if (text != null)
            mInputView.setText(text);

        mInputView.addTextChangedListener(new InputTextWatcher());

        if (mDivider != null) {
            mDivider.setAnimEnable(false);
            ViewUtil.setBackground(mInputView, mDivider);
            mDivider.setAnimEnable(true);
        }
    } else
        ViewUtil.applyStyle(mInputView, attrs, defStyleAttr, defStyleRes);
    mInputView.setVisibility(View.VISIBLE);
    mInputView.setFocusableInTouchMode(true);

    for (int i = 0, count = a.getIndexCount(); i < count; i++) {
        int attr = a.getIndex(i);

        if (attr == R.styleable.EditText_et_labelEnable)
            mLabelEnable = a.getBoolean(attr, false);
        else if (attr == R.styleable.EditText_et_labelPadding)
            labelPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextSize)
            labelTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextColor)
            labelTextColor = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_labelTextAppearance)
            getLabelView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_labelEllipsize) {
            int labelEllipsize = a.getInteger(attr, 0);
            switch (labelEllipsize) {
            case 1:
                getLabelView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getLabelView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getLabelView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_labelInAnim)
            mLabelInAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_labelOutAnim)
            mLabelOutAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_supportMode)
            mSupportMode = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_supportPadding)
            supportPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextSize)
            supportTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextColor)
            supportColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextErrorColor)
            supportErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextAppearance)
            getSupportView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_supportEllipsize) {
            int supportEllipsize = a.getInteger(attr, 0);
            switch (supportEllipsize) {
            case 1:
                getSupportView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getSupportView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getSupportView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_supportMaxLines)
            getSupportView().setMaxLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportLines)
            getSupportView().setLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportSingleLine)
            getSupportView().setSingleLine(a.getBoolean(attr, false));
        else if (attr == R.styleable.EditText_et_supportMaxChars)
            mSupportMaxChars = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_helper)
            supportHelper = a.getString(attr);
        else if (attr == R.styleable.EditText_et_error)
            supportError = a.getString(attr);
        else if (attr == R.styleable.EditText_et_inputId)
            mInputView.setId(a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_dividerColor)
            dividerColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerErrorColor)
            dividerErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerHeight)
            dividerHeight = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerPadding)
            dividerPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerAnimDuration)
            dividerAnimDuration = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerCompoundPadding)
            mDividerCompoundPadding = a.getBoolean(attr, true);
    }

    a.recycle();

    if (mInputView.getId() == 0)
        mInputView.setId(ViewUtil.generateViewId());

    if (mDivider == null) {
        mDividerColors = dividerColors;
        mDividerErrorColors = dividerErrorColors;

        if (mDividerColors == null) {
            int[][] states = new int[][] { new int[] { -android.R.attr.state_focused },
                    new int[] { android.R.attr.state_focused, android.R.attr.state_enabled }, };
            int[] colors = new int[] { ThemeUtil.colorControlNormal(context, 0xFF000000),
                    ThemeUtil.colorControlActivated(context, 0xFF000000), };

            mDividerColors = new ColorStateList(states, colors);
        }

        if (mDividerErrorColors == null)
            mDividerErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

        if (dividerHeight < 0)
            dividerHeight = 0;

        if (dividerPadding < 0)
            dividerPadding = 0;

        if (dividerAnimDuration < 0)
            dividerAnimDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime);

        mDividerPadding = dividerPadding;
        mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);

        mDivider = new DividerDrawable(dividerHeight,
                mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0, mDividerColors,
                dividerAnimDuration);
        mDivider.setInEditMode(isInEditMode());
        mDivider.setAnimEnable(false);
        ViewUtil.setBackground(mInputView, mDivider);
        mDivider.setAnimEnable(true);
    } else {
        if (dividerHeight >= 0 || dividerPadding >= 0) {
            if (dividerHeight < 0)
                dividerHeight = mDivider.getDividerHeight();

            if (dividerPadding >= 0)
                mDividerPadding = dividerPadding;

            mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);
            mDivider.setDividerHeight(dividerHeight);
            mDivider.setPadding(mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                    mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0);
        }

        if (dividerColors != null)
            mDividerColors = dividerColors;

        if (dividerErrorColors != null)
            mDividerErrorColors = dividerErrorColors;

        mDivider.setColor(getError() == null ? mDividerColors : mDividerErrorColors);

        if (dividerAnimDuration >= 0)
            mDivider.setAnimationDuration(dividerAnimDuration);
    }

    if (labelPadding >= 0)
        getLabelView().setPadding(mDivider.getPaddingLeft(), 0, mDivider.getPaddingRight(), labelPadding);

    if (labelTextSize >= 0)
        getLabelView().setTextSize(TypedValue.COMPLEX_UNIT_PX, labelTextSize);

    if (labelTextColor != null)
        getLabelView().setTextColor(labelTextColor);

    if (mLabelEnable) {
        mLabelVisible = true;
        getLabelView().setText(mInputView.getHint());
        addView(getLabelView(), 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        setLabelVisible(!TextUtils.isEmpty(mInputView.getText().toString()), false);
    }

    if (supportTextSize >= 0)
        getSupportView().setTextSize(TypedValue.COMPLEX_UNIT_PX, supportTextSize);

    if (supportColors != null)
        mSupportColors = supportColors;
    else if (mSupportColors == null)
        mSupportColors = context.getResources().getColorStateList(R.color.abc_secondary_text_material_light);

    if (supportErrorColors != null)
        mSupportErrorColors = supportErrorColors;
    else if (mSupportErrorColors == null)
        mSupportErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

    if (supportPadding >= 0)
        getSupportView().setPadding(mDivider.getPaddingLeft(), supportPadding, mDivider.getPaddingRight(), 0);

    if (supportHelper == null && supportError == null)
        getSupportView().setTextColor(getError() == null ? mSupportColors : mSupportErrorColors);
    else if (supportHelper != null)
        setHelper(supportHelper);
    else
        setError(supportError);

    if (mSupportMode != SUPPORT_MODE_NONE) {
        switch (mSupportMode) {
        case SUPPORT_MODE_CHAR_COUNTER:
            getSupportView().setGravity(Gravity.END);
            updateCharCounter(mInputView.getText().length());
            break;
        case SUPPORT_MODE_HELPER:
        case SUPPORT_MODE_HELPER_WITH_ERROR:
            getSupportView().setGravity(GravityCompat.START);
            break;
        }
        addView(getSupportView(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }

    addView(mInputView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    requestLayout();
}