In the below example I have Created a Popup function, so when we will click on CardView it shows Popup on our screen and when we will click outside popup then automatically popup window will close.
For this First I have added I have added RecyclerView , CardView and design support library in build.gradle file. After then I have created RecyclerView and FloatingActionButton within Framelayout in main_activity.xml layout, then In next step I have created a new dialog.xml layout here I have added TextView, EditView, Button and Spinner.
After then in fourth step I have created a new item_recycler.xml layout here I have added CardView, ImageView and TextView.
Now see programming area here I have created Friend class and MyAdapter class within MyAdapter class I have created ViewHolder class and In MainActivity I have used DialogBox fuction. You can see below program it will clearly describe you to add floating action button with RecyclerView xml layout in android.
Step(1)-I have added RecyclerView, CardView and design library in build.gradle file -