XPopup

Powerful, simple UI, interactive elegant universal popover! Can replace Dialog, PopupWindow, PopupMenu, BottomSheet and other components, with more than ten kinds of good animation, support full UI and animation customization!

This library was written for the following reasons:

  1. Projects have common requirements such as pop-up and even drag-and-drop dialogs in the middle and bottom, PopupMenu or PopupWindow in the specified position, and pop-up layer effects for area shadows
  2. The existing class libraries on the market are either not functional enough or have imperfect interactions, and have common shortcomings, just like the problem with BottomSheet. For example, if the window disappears and the background gradient animation is inconsistent, the translucent background remains for a while after the window disappears

Design idea:

Based on common popover scenarios, I divide them into three categories:

  1. Center: pop-ups in the middle, such as confirm and cancel pop-ups and Loading pop-ups
  2. Bottom type, is the pop-up from the Bottom of the page, such as the pop-up from the Bottom of the share form, zhihu from the Bottom of the pop-up comment list
  3. Attach type, that is, the popover position needs to be attached to a View, just like the PopupMenu effect of the system, but with strong customization

Animation design:

In order to make the interaction more interesting, we follow the Material Design and consider many details, transitions and changes of levels in the animation Design. You can see this in the Demo.

Gradle

implementation 'com.lxj:xpopup:latest release'
Copy the code

ScreenShot

use

For ease of use, several common popover implementations have been built in:

  1. Displays the confirm and cancel dialog boxes

    XPopup.get(getContext()).asConfirm("I am the title."."I am the content".new OnConfirmListener() {
                                @Override
                                public void onConfirm(a) {
                                   toast("click confirm");
                                }
                            })
                            .show();
    Copy the code
  2. Displays confirmation and cancel dialog boxes with input boxes

    XPopup.get(getContext()).asInputConfirm("I am the title."."Please enter the content.".new OnInputConfirmListener() {
                                @Override
                                public void onConfirm(String text) {
                                    toast("input text: " + text);
                                }
                            })
                            .show();
    Copy the code
  3. Displays a list popup window in the middle

    XPopup.get(getActivity()).asCenterList("Please select one".new String[]{"Item 1"."Item 2"."Three entries"."Item 4"},
                            new OnSelectListener() {
                                @Override
                                public void onSelect(int position, String text) {
                                    toast("click "+text);
                                }
                            })
                            .show();
    Copy the code
  4. The loading box is displayed

    XPopup.get(getActivity()).asLoading().show();
    Copy the code
  5. Displays a list popup from the bottom

    XPopup.get(getActivity()).asBottomList("Please select one".new String[]{"Item 1"."Item 2"."Three entries"."Item 4"."Item 5"},
                            new OnSelectListener() {
                                @Override
                                public void onSelect(int position, String text) {
                                    toast("click "+text);
                                }
                            })
                            .show();
    Copy the code
  6. Displays a popover attached to a View

    XPopup.get(getActivity()).asAttachList(new String[]{"Share"."Edit"."Without the icon"},
                            new int[]{R.mipmap.ic_launcher, R.mipmap.ic_launcher},
                            new OnSelectListener() {
                                @Override
                                public void onSelect(int position, String text) {
                                    toast("click "+text);
                                }
                            })
                            .atView(v)  // Attached to the clicked View, must be set
                            .show();
    Copy the code
  7. Close Windows

    XPopup.get(getContext()).dismiss();
    Copy the code
  8. See the Github Readme description for more information about how to use it.

contact

Github:github.com/li-xiaojun/…

QQ: 16167479

This library is just released, I really need your suggestions or ideas, please don’t be too generous with your needs, and make an issue on Github.