Home > Blockchain >  how to use fragments to create an overlay effect for an add contact function when a button is presse
how to use fragments to create an overlay effect for an add contact function when a button is presse

Time:12-23

I'm trying to create an overlay that is triggered when a button is pressed. This overlay is supposed to allow the user to add their contact and I was wondering how can I use fragments to get this effect like you can see in this mockup.Adobe XD Mockup I am in a dilemna over using fragments is the right choice. My reasoning being that I only need to have it do one task that is adding contacts, and thus I do not need a whole activity.

This is what I have on the main activity right nowMain Activity Java File Main Activity xml File

I would really appreciate any help on understanding how to make this work.

CodePudding user response:

You can use a DialogFragment. It behaves like a normal Fragment for the most part. Here is a guide for a basic implementation https://guides.codepath.com/android/using-dialogfragment

They appear automatically in the center of the screen. To get it a bit lower like in your mockup you can change where it is in the window. Here is an answer showing such Position of DialogFragment in Android

  • Related