Android仿简书创作弹起弹框

Android仿简书创作弹起弹框

主要是弹框由上往下和由下往上的动画进入效果

一、思路:

定义动画效果的xml

二、效果图:

看视频更直观点:

Android开发轮子-仿简书创作弹起弹框

三、关键代码:
java 复制代码
public class DialogUtils {

    public static AlertDialog getAlertDialog(Context context) {
        return new AlertDialog.Builder(context, R.style.mydialog).setCancelable(true).create();
    }

    public static Dialog showTopDialog(final Context mContext){
        final AlertDialog dialog = getAlertDialog(mContext);
        dialog.show();
        final Window window = dialog.getWindow();
        window.setGravity(Gravity.TOP);
        window.setContentView(R.layout.dialog_create);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);

        window.setWindowAnimations(R.style.AnimTop);
        return dialog;
    }

    public static Dialog showBottomDialog(final Context mContext){
        final AlertDialog dialog = getAlertDialog(mContext);
        dialog.show();
        final Window window = dialog.getWindow();
        window.setGravity(Gravity.BOTTOM);
        window.setContentView(R.layout.dialog_create);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);

        window.setWindowAnimations(R.style.AnimBottom);
        return dialog;
    }
}
四、项目demo源码结构图:

有问题或者完整源码demo的私信我,我每天都看私信的

相关推荐
有位神秘人13 分钟前
Android中获取设备里面的音频文件
android
2501_9159184142 分钟前
使用 HBuilder 上架 iOS 应用时常见的问题与应对方式
android·ios·小程序·https·uni-app·iphone·webview
farewell-Calm1 小时前
01_Android快速入门
android
helloCat2 小时前
记录CI/CD自动化上传AppGallery遇到的坑
android·前端·api
WordPress学习笔记2 小时前
wordpress根据页面别名获取该页面的链接
android·wordpress
2501_916007472 小时前
iOS 崩溃日志的分析方法,将崩溃日志与运行过程结合分析
android·ios·小程序·https·uni-app·iphone·webview
浅箬3 小时前
Taro3的H5项目在Android、IOS 中因为兼容性问题导致的白屏问题
android·团队开发·taro
技术摆渡人3 小时前
Android 全栈架构终极指南:从 Linux 内核、Binder 驱动到 Framework 源码实战
android·linux·架构
00后程序员张3 小时前
苹果应用商店上架App流程,签名证书、IPA 校验、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_916007473 小时前
iOS 上架需要哪些准备,围绕证书、描述文件和上传方式等关键环节展开分析
android·ios·小程序·https·uni-app·iphone·webview