I'm thinking of a way to make a view with the visibility: gone
attribute visible by clicking on the screen long and disappear as soon as you drop, look like, and the Instagram thing. Any ideas how to do it?
You can do this by using the setOnTouchListener
event within this event, you will come across the onTouch
method that will redeem the action that the user is using, 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;
}
});