
How to remove or change the search view icon inside the edittext? I am using the Appcompat libra
remove is the right drawable that you have mentioned in xml:
final Drawable remove = ContextCompat.getDrawable(getActivity(), R.drawable.ic_close_circle);
etSearchProducts.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (etSearchProducts.getCompoundDrawables()[2] == null) {
return false;
}
if (event.getAction() != MotionEvent.ACTION_UP) {
return false;
}
if (event.getX() > etSearchProducts.getWidth() - etSearchProducts.getPaddingRight() - remove.getIntrinsicWidth()) {
etSearchProducts.setText("");
Utility.hideKeyboard(getActivity());
}
return false;
}
});