The action to close view pager is handled by the parent activity or fragment that contains the ViewPager. If you are using it inside an acvitiy, use finish(); and if it's inside a fragment, call requireActivity().getSupportFragmentManager().popBackStack(); Hope it helps you