【问题标题】: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();