Object appears when starting (pressing) the OnLongClickListener event and disappears when it finishes (drop)

0

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?

    
asked by anonymous 22.10.2017 / 16:55

1 answer

0

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;
        }
    });
    
23.10.2017 / 15:46