S
S
SimpleName2019-01-17 09:25:47
Java
SimpleName, 2019-01-17 09:25:47

How to close a view by clicking on an empty space?

There is a Floating Button, when clicked, the cardview appears, and the fab disappears.

Code Example
fab = (FloatingActionButton) view.findViewById(R.id.fab);
        cardView = (CardView) view.findViewById(R.id.map_cardview);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fab.hide();
                cardView.setVisibility(View.VISIBLE);
            }
        });


Is it possible to make the same cardview close when you click on an empty space in the fragment (this area is marked in red on the screenshot) and the fab reappears?
Here is a screenshot
5c40205985033684486333.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-01-17
@SimpleName

The easiest option is to make a FrameLayout for the entire area that you want to click on, and catch clicks on it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question