/** * Sets the Drawables (if any) to appear to the start of, above, to the end * 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 #setCompoundDrawables} or related methods. * * @attr ref android.R.styleable#TextView_drawableStart * @attr ref android.R.styleable#TextView_drawableTop * @attr ref android.R.styleable#TextView_drawableEnd * @attr ref android.R.styleable#TextView_drawableBottom */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) mInputView.setCompoundDrawablesRelative(start, top, end, bottom); else mInputView.setCompoundDrawables(start, top, end, bottom); }
@Override public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) { super.setCompoundDrawables(left, top, right, bottom); updateTint(); }
final EditText et=(EditText) findViewById(R.id.editText1); et.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View arg0, boolean gotfocus) { // TODO Auto-generated method stub if(gotfocus){ et.setCompoundDrawables(null, null, null, null); } else if(!gotfocus){ if(et.getText().length()==0) et.setCompoundDrawablesWithIntrinsicBounds(R.drawable.yourimage, 0, 0, 0); } } });
et.setCompoundDrawables(null, null, null, null); @Override public void onTextChanged(CharSequence s, int start, int before, int count) { et.setCompoundDrawables(null, null, et.getText().toString().equals("") ? null : x, null);
final EditText et=(EditText) findViewById(R.id.text1); et.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View arg0, boolean gotfocus) { // TODO Auto-generated method stub if(gotfocus) { et.setCompoundDrawables(null, null, null, null); } else if(!gotfocus) { if(et.getText().length()==0) et.setCompoundDrawablesWithIntrinsicBounds(R.drawable.youricon, 0, 0, 0); } } });
et.setCompoundDrawables(null, null, null, null); @Override public void onTextChanged(CharSequence s, int start, int before, int count) { et.setCompoundDrawables(null, null, et.getText().toString().equals("") ? null : x, null);
/** * 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 void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { if (right != null) { this.dRight = right; } super.setCompoundDrawables(left, top, right, bottom); }
@Override public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { if (right != null) { this.dRight = right; } super.setCompoundDrawables(left, top, right, bottom); }
public void setCompoundDrawables(Drawable paramDrawable1, Drawable paramDrawable2, Drawable paramDrawable3, Drawable paramDrawable4) { if (paramDrawable3 != null) this.dRight = paramDrawable3; super.setCompoundDrawables(paramDrawable1, paramDrawable2, paramDrawable3, paramDrawable4); }
@Override public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) { super.setCompoundDrawables(left, top, mDropDownDrawable != null ? mDropDownDrawable : right, bottom); }
@Override public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { //keep a reference to the right drawable so later on touch we can check if touch is on the drawable if (leftToRight && right != null) { drawableEnd = right; } else if (!leftToRight && left != null) { drawableEnd = left; } if(drawableEnd != null) // 点击范围太小了,容易点不到,故增加drawable大小 drawableEnd.setBounds(0,0, DimenUtils.dpToPxInt(35),DimenUtils.dpToPxInt(35)); super.setCompoundDrawables(left, top, right, bottom); }
/** */ @Override public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { super.setCompoundDrawables(left, top, right, bottom); this.ensureDecorator(); mDecorator.applyCompoundDrawablesTint(); }
/** */ @Override public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { super.setCompoundDrawables(left, top, right, bottom); this.ensureDecorator(); mDecorator.applyCompoundDrawablesTint(); }
/** */ @Override public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) { super.setCompoundDrawables(left, top, right, bottom); this.ensureDecorator(); mDecorator.applyCompoundDrawablesTint(); }
Drawable x3 = viewMode.equals("never")?null:viewMode.equals("always")?x:viewMode.equals("editing")?null:viewMode.equals("unlessEditing")?x:null; et.setText(""); et.setCompoundDrawables(viewSide.equals("left")?x3:null, null, viewSide.equals("right")?x3:null, null); public void onTextChanged(CharSequence s, int start, int before, int count) { Drawable x4 = viewMode.equals("never")?null:viewMode.equals("always")?x:viewMode.equals("editing")?(et.getText().toString().equals("") ? null : x):viewMode.equals("unlessEditing")?(et.getText().toString().equals("") ? x : null):null; et.setCompoundDrawables(viewSide.equals("left")?x4:null, null, viewSide.equals("right")?x4:null, null);
@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); } }