/** * 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' bounds will be set to their intrinsic * bounds. * <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 setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top, Drawable right, Drawable bottom){ mInputView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); }
/** * Sets the Drawables (if any) to appear to the left of, above, to the * right of, and below the text. Use 0 if you do not want a Drawable there. * The Drawables' bounds will be set to their intrinsic bounds. * <p> * Calling this method will overwrite any Drawables previously set using * {@link #setCompoundDrawablesRelative} or related methods. * * @param left Resource identifier of the left Drawable. * @param top Resource identifier of the top Drawable. * @param right Resource identifier of the right Drawable. * @param bottom Resource identifier of the bottom Drawable. * * @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 setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom){ mInputView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); }
@Override public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) { if (mCompoundDrawableHelper != null) { mCompoundDrawableHelper.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); } else { super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); } }
@Override public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) { super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); if (mCompoundDrawableHelper != null) { mCompoundDrawableHelper.setCompoundDrawablesWithIntrinsicBounds(); } }
/** * 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' bounds will be set to their intrinsic bounds. * <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 setCompoundDrawablesRelativeWithIntrinsicBounds (Drawable start, Drawable top, Drawable end, Drawable bottom){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) mInputView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom); else mInputView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); }
/** * Sets the Drawables (if any) to appear to the start of, above, to the end * of, and below the text. Use 0 if you do not want a Drawable there. The * Drawables' bounds will be set to their intrinsic bounds. * <p> * Calling this method will overwrite any Drawables previously set using * {@link #setCompoundDrawables} or related methods. * * @param start Resource identifier of the start Drawable. * @param top Resource identifier of the top Drawable. * @param end Resource identifier of the end Drawable. * @param bottom Resource identifier of the bottom Drawable. * * @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 setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, int end, int bottom){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) mInputView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom); else mInputView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); }
private void prepareEditMode() { getWindow().setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN); Drawable dr = ContextCompat.getDrawable(this, R.drawable.ic_content_copy_black_24dp); mIdView.setCompoundDrawablesWithIntrinsicBounds(null, null, dr, null); mIdView.setEnabled(false); mQrButton.setVisibility(GONE); mIdContainer.setOnClickListener(this); }
String spacer=" "; EditText myEditText= (EditText)findViewById(R.id.myEditText); myEditText.setText(spacer + "Today"); myEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_calendar, 0, 0, 0);
EditText msg; msg = (EditText) findViewById(R.id.message); msg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); msg.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (msg.getText().toString().equalsIgnoreCase("android")) msg.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_launcher, 0); else msg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } });
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); } } });
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); } } });
EditText myEdit = (EditText)findViewById(R.id.my_edit); if (TextUtils.isEmpty(myEdit.getText().toString())) { // set the warning myEdit.requestFocus(); // show error icon myEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.error_sign, 0); // remove the error icon on key press myEdit.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { EditText eText = (EditText)v; // remove error sign eText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); // remove this key handler eText.setOnKeyListener(null); return false; } }); }
@SuppressWarnings("ResourceType") @Override public void setCustomStyle(View sheetView) { if (style != 0) { int[] attrs = { android.R.attr.textColor, android.R.attr.textColorHint, android.R.attr.background, android.R.attr.drawable }; TypedArray ta = sheetView.getContext().obtainStyledAttributes(style, attrs); textColor = ta.getColor(0, Color.BLACK); hintColor = ta.getColor(1, Color.GRAY); backgroundColor = ta.getColor(2, Color.WHITE); searchIconId = ta.getResourceId(3, R.drawable.ic_search); searchEditText.setTextColor(textColor); searchEditText.setHintTextColor(hintColor); searchIcon = ContextCompat.getDrawable(searchEditText.getContext(), searchIconId); if (searchIconId == R.drawable.ic_search) { searchIcon.setColorFilter(new PorterDuffColorFilter(hintColor, PorterDuff.Mode.SRC_ATOP)); } searchEditText.setCompoundDrawablesWithIntrinsicBounds(searchIcon, null, null, null); rootView.setBackgroundColor(backgroundColor); ta.recycle(); } }
final ListView listview = new ListView(context); filterEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_search_white, 0, 0, 0); filterEditText.setInputType(InputType.TYPE_CLASS_TEXT);
mOriginEditText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mTextFieldClearIconRes, 0); mDestinationEditText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mTextFieldClearIconRes, 0);
public void setRevealIconVisibility(final boolean isVisible) { Drawable revealDrawable = passwordField.getCompoundDrawables()[DRAWABLE_RIGHT]; if (isVisible) { isRevealIconVisible = true; if (revealDrawable == null) { revealDrawable = ContextCompat.getDrawable(getContext(), R.drawable.kinrecovery_grey_reveal_icon); passwordField.setCompoundDrawablesWithIntrinsicBounds(null, null, revealDrawable, null); } else { revealDrawable.setVisible(true, true); } } else { isRevealIconVisible = false; if (revealDrawable != null) { revealDrawable.setVisible(false, true); } } }
private void cancelPrivateThingUiAndAddAction() { togglePrivateThingActionItem(mActionbar.getMenu(), true); mEtTitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); int paddingSide = (int) (screenDensity * 20); mEtTitle.setPadding(paddingSide, mEtTitle.getPaddingTop(), paddingSide, 0); }
private void setAsPrivateThingUiAndAddAction() { mEtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_locked_small, 0, 0, 0); int paddingSide = (int) (screenDensity * 16); mEtTitle.setPadding(paddingSide, mEtTitle.getPaddingTop(), paddingSide, 0); if (shouldAddToActionList) { mActionList.addAction( new ThingAction(ThingAction.TOGGLE_PRIVATE, null, null)); } }
); } else { mWidget.setCompoundDrawablesWithIntrinsicBounds( compoundDrawables[0], compoundDrawables[1],
); } else { mWidget.setCompoundDrawablesWithIntrinsicBounds( compoundDrawables[0], compoundDrawables[1],