先来看下效果图:
其中show和dismiss的时候有动画效果。
原先试过使用PopupWindow来做,但是使用的时候不是那么舒服,毕竟不是dialog嘛。
所以这次尝试还是使用dialog来做 ,很多地方是引用了系统源码(源码是最好的老师)
首先看CustomDialog.java的构造函数:
protected CustomDialog(Context context) {
this(context, R.style.CustomDialog);
}
protected CustomDialog(Context context, int theme) {
super(context, theme);
mAlert = new AlertController(context, this, getWindow());
Window window = getWindow();
window.setGravity(Gravity.BOTTOM); // 设置window的位置为底部
window.setWindowAnimations(R.style.AnimationDialog); // 设置window的动画
window.setBackgroundDrawableResource(android.R.color.transparent); // 设置wi

本文介绍了如何在Android中模仿MIUI的Dialog,包括展示和消失时的动画效果。作者通过分析系统源码并结合自定义Dialog,提供了一种实现方案,并分享了源码下载链接,但指出源码中存在小问题,需要在AlertController中添加代码来完善。
最低0.47元/天 解锁文章
236

被折叠的 条评论
为什么被折叠?



