0
You can do this way using the event setOnTouchListener, within this event, you will come across the method onTouch that will rescue the action that the user is using, the ACTION_DOWN, for when the user is holding the button and ACTION_UP, for when the user releases the button:
my_btn.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// Abra sua View
} else if (event.getAction() == MotionEvent.ACTION_UP) {
// Feche sua View
}
return false;
}
});
