1

I am trying to make a android app, so that when i click a particular view it takes it to the front of every view and let other views stay behind it becoming slightly dim in color . E.g: This whatsapp profile show layout.( the profile is on top of every thing and we can interact with it)

I want to know the relevant keywords, topics or name of particular widgets to learn to finally implement this view along with the animation. Any approach to reach the solution would also be appreciated .

I have tried using different ways bring image to front, etc.. but that didn't solve the problem .

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Hissaan Ali
  • 2,229
  • 4
  • 25
  • 51

5 Answers5

1

You can achieve this by creating a custom alert dialog and inflating a layout into it.

public class CvvHelpDialog extends Dialog {

    public CvvHelpDialog(@NonNull Activity context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_cvv_help);

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.copyFrom(getWindow().getAttributes());
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        getWindow().setAttributes(lp);

    }
}

For R.layout.dialog_cvv_help, you can design a layout as your requirement. You can display it by simply using the below lines of code.

CvvHelpDialog cvvDialog = new CvvHelpDialog(getActivity());
cvvDialog.show();
1

Create an activity or fragment with a transparent background and image to the center of the activity or fragment. And just start the new activity or display the fragment.

Or you can also use a DialogFragment for this purpose.

You can use Element transition for the animation to pop a view to the front from other like WhatsApp profile picture.

Milan Joseph
  • 118
  • 10
1

You can use Dialog . The screen behind dialog automatically get dim.You don't have to do anything.

https://androidexample.com/Custom_Dialog_-_Android_Example/index.php?view=article_discription&aid=88

Roushan Kumar
  • 79
  • 1
  • 5
1

Just Create dialog and add your custom view for doing this...like this

AlertDialog.Builder builder =new AlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.custom_layout,null);
builder.setView(view);
builder.show();

when dialog will appear..background will be transparent automatically.

Prachi Singh
  • 564
  • 3
  • 8
0

You can create a view with the custom view in the center and gray background around this view in the same layout. And when you will need to show - make it visible and set isEnable = false for background viewgroup

Edhar Khimich
  • 1,468
  • 1
  • 17
  • 20