【问题标题】:How to Create an Android Modal Popup with Animation?如何使用动画创建 Android 模态弹出窗口?
【发布时间】:2017-06-02 07:55:21
【问题描述】:

我正在尝试在 Android 中创建类似于this(10 秒)的模态弹出效果。我想弹出一个带有 TextView 和 WebView 的“窗口”,带有动画并且背景模糊或变暗。我已经搜索并遇到了 AlertDialog、PopupWindow 和 Activity Dialogs,但我不确定其中哪一个(如果有的话)最合适。实现这一目标的最佳方法是什么?

【问题讨论】:

    标签: android dialog popup modal-dialog alert


    【解决方案1】:

    为此使用对话框:

    public class AppDialog extends Dialog {
    
     View mainView;
     public AppDialog(@NonNull Context context) {
     super(context);
     mainView = LayoutInflater.from(context).inflate(R.layout.app_date_picker_dialog,null);
     addContentView(mainView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
     }
    }
    

    调用你的活动:

    AppDialog dialog = new AppDialog(context);
    dialog.show();
    

    【讨论】:

    • 谢谢!您将如何为弹出和关闭对话框设置动画?
    猜你喜欢
    • 2014-05-26
    • 1970-01-01
    • 2021-10-17
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    相关资源
    最近更新 更多