What is the difference between PopUpWindow and Dialog?

后端 未结 3 1467
小蘑菇
小蘑菇 2021-02-13 04:07

Basically the question is stated in the title. Any preferences in using one or another? Maybe some specific tasks where one is superior/ more efficient/ better than the other?

3条回答
  •  囚心锁ツ
    2021-02-13 04:38

    Dialog

    "A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed."

    AlertDialog has many variants and as far as I can assume your problem, You can have a cross button too in the top-right corner of the dialog (You can set the icons anywhere, as you can provide a custom layout to an AlertDialog).

    -Capable of adding any view

    -Easy to edit

    -Can be adapted to tablets or cellphones in landscape or portrait just by modifying the layout

    -Can dedicate a whole new class just to modify it your way

    PopupWindows

    "This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity."

    PopupWindow is another tool to customize your custom pop up anywhere in the screen. If you're showing this popup always in the middle of the screen, then I would like to suggest not to use this. The AlertDialog should work fine.

    -Simpler

    -Easier to code

    -It's more standard so it'll be harder for the user to be confused with it

提交回复
热议问题