У меня есть следующие EditText
:андроид изменение цвета иконы из EditText
editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_bottom_right_black_18dp, 0);
и я пытаюсь изменить цвет ic_arrow_bottom_right_black_18dp
программно с помощью следующих методов:
protected void setEditTextDisabled(EditText editText) {
editText.setFocusable(false);
editText.setClickable(false);
editText.setEnabled(false);
editText.setTextColor(ContextCompat.getColor(getContext(), R.color.package_components_group_text_color));
if (editText.getTag(R.id.values_list_selected_ids) == null) {
if (editText.getTag(R.id.values_list_selected_ids) == null) {
editText.setFocusableInTouchMode(true);
Drawable[] d = editText.getCompoundDrawables();
if (d.length == 4) {
d[2].setColorFilter(ContextCompat.getColor(getContext(), R.color.package_components_group_text_color), PorterDuff.Mode.SRC_ATOP);
}
}
}
Drawable background = editText.getBackground();
if (background instanceof ShapeDrawable) {
// ((ShapeDrawable)background).getPaint().setStroke(2, getResources().getColor(R.color.package_components_group_text_color));
// ((ShapeDrawable)background).getPaint().setStroke(2, getResources().getColor(R.color.package_components_group_text_color));
} else if (background instanceof GradientDrawable) {
((GradientDrawable)background).setStroke(2, getResources().getColor(R.color.package_components_group_text_color));
} else if (background instanceof ColorDrawable) {
// ((ColorDrawable)background).setStroke(2, getResources().getColor(R.color.package_components_group_text_color));
}
}
protected void setEditTextEnabled(EditText editText) {
editText.setEnabled(true);
editText.setFocusable(true);
editText.setClickable(true);
editText.setTextColor(ContextCompat.getColor(getContext(), R.color.black));
if (editText.getTag(R.id.values_list_selected_ids) == null) {
editText.setFocusableInTouchMode(true);
Drawable[] d = editText.getCompoundDrawables();
if (d.length == 4) {
d[2].setColorFilter(ContextCompat.getColor(getContext(), R.color.black), PorterDuff.Mode.SRC_ATOP);
}
}
Drawable background = editText.getBackground();
if (background instanceof ShapeDrawable) {
// ((ShapeDrawable)background).getPaint().setColor(getResources().getColor(R.color.black));
} else if (background instanceof GradientDrawable) {
((GradientDrawable)background).setStroke(2, getResources().getColor(R.color.black));
} else if (background instanceof ColorDrawable) {
// ((ColorDrawable)background).setColor(getResources().getColor(R.color.black));
}
}
вопрос является что выталкиваемая правая иконка EditText
становится невидимой или белой, когда вызывается один из вышеперечисленных методов.
Прикрепленный файл с изображением текста редактирования, который расположен с правой стороны.
метод setColorFilter недоступен для edittext, и я не пытаюсь изменить цвет edittext, но значок edittext. – aurelianr
применить его на значке –
Как я могу получить значок из текста редактирования? – aurelianr