Skip to content

Instantly share code, notes, and snippets.

@nandha-dev
Created June 20, 2015 10:06
Show Gist options
  • Save nandha-dev/afafda18f3f7e22885af to your computer and use it in GitHub Desktop.
Save nandha-dev/afafda18f3f7e22885af to your computer and use it in GitHub Desktop.
For drawable right on click
editText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= (editText.getRight() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
// your action here
return true;
}
}
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment