Kes Walker
Kes Walker

Reputation: 1493

Android: How to create a custom dropdown dialog?

I need to create a dialog which drops down from a clicked position on the screen.

I have considered using a floating ContextMenu, but I need to customize the contents of the dropdown to display my own views.

context menu

I have also considered using a custom DialogFragment but this is not subtle enough and interrupts the flow.

enter image description here

How can I create something in between?

A perfect example would be the dropdown dialog used by Duolingo:

good example

I have also considered just adding a framelayout to the point where the user clicks but I'm not sure how to recreate the dept of a ContextMenu or how to create a decent animation when the dialog is fading in and out.

I dont want to display a list of options within the dialog, I want to display a custom layout with a number of textviews and buttons.

Upvotes: 0

Views: 1423

Answers (1)

Mahmoud Waked
Mahmoud Waked

Reputation: 405

Check these libraries, it will help you

https://github.com/MasayukiSuda/BubbleLayout?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=3564

https://github.com/piruin/quickaction?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=5746

You can also make it without library:

  1. Create custom dialog
  2. Set dialog animation

    override Dialog onCreateDialog(Bundle savedInstanceState){
        ...
        Dialog dialog = new Dialog(context);
        dialog.setWindowAnimations(R.style.anim_dropdown);
        return dialog;
    }
    
  3. Changing position of the Dialog on screen android

Upvotes: 1

Related Questions