/** * Returns the total right padding of the view, including the right * Drawable if any. */ public int getTotalPaddingRight (){ return getPaddingRight() + mInputView.getTotalPaddingRight(); }
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); mDivider.setPadding(mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0, mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0);
/** * Sets the size of the padding between the compound drawables and * the text. * * @attr ref android.R.styleable#TextView_drawablePadding */ public void setCompoundDrawablePadding (int pad){ mInputView.setCompoundDrawablePadding(pad); if(mDividerCompoundPadding) { mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight()); if(mLabelEnable) mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom()); if(mSupportMode != SUPPORT_MODE_NONE) mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom()); } }
/** * Sets the Drawables (if any) to appear to the left of, above, to the * right of, and below the text. Use {@code null} if you do not want a * Drawable there. The Drawables must already have had * {@link Drawable#setBounds} called. * <p> * Calling this method will overwrite any Drawables previously set using * {@link #setCompoundDrawablesRelative} or related methods. * * @attr ref android.R.styleable#TextView_drawableLeft * @attr ref android.R.styleable#TextView_drawableTop * @attr ref android.R.styleable#TextView_drawableRight * @attr ref android.R.styleable#TextView_drawableBottom */ public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom){ mInputView.setCompoundDrawables(left, top, right, bottom); if(mDividerCompoundPadding) { mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight()); if(mLabelEnable) mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom()); if(mSupportMode != SUPPORT_MODE_NONE) mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom()); } }
@Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= searchKeyEditText.getRight() - searchKeyEditText.getTotalPaddingRight()) { searchKeyEditText.setText(""); return true; } } return false; } });
@Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (dialog.editText.getCompoundDrawables()[2] != null) { boolean touchable = event.getX() > (dialog.editText.getWidth() - dialog.editText.getTotalPaddingRight()) && (event.getX() < ((dialog.editText.getWidth() - dialog.editText.getPaddingRight()))); if (touchable) { dialog.editText.setText(""); } } } return false; } });