I have a RecyclerView with 2 items that don\'t fill the whole screen. How can I detect that the user clicked on the empty part of the RecyclerView (meaning clicked directly on t
You just need to set a TouchListener
on the RecyclerView
like shown above :
categoryTable.setAdapter(new CatgoriesAdapter(categories.getWrappedList()));
categoryTable.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN
&& categoryTable.findChildViewUnder(event.getX(), event.getY()) == null)
{
// Touch outside items here, you do whatever you want
HideCategoryMenu();
}
return false;
}
});