/** * Returns drawables for the left, top, right, and bottom borders. * * @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 Drawable[] getCompoundDrawables (){ return mInputView.getCompoundDrawables(); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public Drawable[] getCompoundDrawablesRelative (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return mInputView.getCompoundDrawablesRelative(); return mInputView.getCompoundDrawables(); }
@Override public boolean onTouch(View v, MotionEvent event) { if (et.getCompoundDrawables()[2] == null) { return false;
@Override public boolean onTouch(View v, MotionEvent event) { if (et.getCompoundDrawables()[2] == null) { return false;
private boolean isPrivateThing() { Drawable start = mEtTitle.getCompoundDrawables()[0]; return start != null; }
/** * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any) * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b> * <p> * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}. */ @NonNull @Override public Drawable[] getCompoundDrawables() { return super.getCompoundDrawables(); }
/** * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any) * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b> * <p> * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}. */ @NonNull @Override public Drawable[] getCompoundDrawables() { return super.getCompoundDrawables(); }
/** * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any) * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b> * <p> * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}. */ @NonNull @Override public Drawable[] getCompoundDrawables() { return super.getCompoundDrawables(); }
public void setRevealIconColor(@ColorRes final int colorRes) { Drawable revealDrawable = passwordField.getCompoundDrawables()[DRAWABLE_RIGHT]; if (revealDrawable != null) { final int color = ContextCompat.getColor(getContext(), colorRes); revealDrawable.setColorFilter(color, Mode.SRC_ATOP); } }
@Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { filterInfo(""); mSearchEditText.setText(""); return true; } } return false; } });
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { Drawable right = charSequence.length() > 0 ? mClearDrawable : null; dialog.editText.setCompoundDrawables(dialog.editText.getCompoundDrawables()[0], dialog.editText.getCompoundDrawables()[1], right, dialog.editText.getCompoundDrawables()[3]); if (charSequence.length() > 0) { dialog.negButton.setBackgroundResource(R.drawable.button_a); dialog.negButton.setTextColor(context.getResources().getColor(R.color.button_a_font_color)); dialog.negButton.setClickable(true); } else { dialog.negButton.setBackgroundResource(R.drawable.dialog_style7_button_bg); dialog.negButton.setTextColor(context.getResources().getColor(R.color.c_BFBFBF)); dialog.negButton.setClickable(false); } }
public static void assertNoHintIcon(EditText editText) { assertNull(editText.getCompoundDrawables()[0]); assertNull(editText.getCompoundDrawables()[1]); assertNull(editText.getCompoundDrawables()[2]); assertNull(editText.getCompoundDrawables()[3]); }
private boolean isInRevealIconBounds(MotionEvent event) { final int drawableWidth = passwordField.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width(); return (event.getRawX() >= (getRight() - drawableWidth - sidesPadding)) && (event.getRawX() <= (getRight() - sidesPadding)); }
@Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { filterInfo(""); mSearchEditText.setText(""); mSearchEditText.clearFocus(); return true; } } return false; } });
@Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { mSearchEditText.setText(""); mSearchEditText.clearFocus(); return true; } } return false; } });
@Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { mSearchEditText.setText(""); mSearchEditText.clearFocus(); return true; } } return false; } });
@Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { mSearchEditText.setText(""); mSearchEditText.clearFocus(); return true; } } return false; } });
@Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { int leftEdgeOfRightDrawable = editText.getRight() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width(); // when EditBox has padding, adjust leftEdge like // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right); if (event.getRawX() >= leftEdgeOfRightDrawable) { // clicked on clear icon editText.setText(""); editText.clearFocus(); 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; } });
public static void assertIconHintIs(EditText editText, int resourceId) { Drawable expected; if (resourceId == 0) { expected = null; } else { expected = RuntimeEnvironment.application.getResources().getDrawable(resourceId); } Drawable[] drawables = editText.getCompoundDrawables(); assertBitmapsEqual(null, drawables[0]); assertBitmapsEqual(null, drawables[1]); assertBitmapsEqual(expected, drawables[2]); assertBitmapsEqual(null, drawables[3]); }