• 底部对话框


        private void showBottomDialog() {
            final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.show();
    
            Window  window = alertDialog.getWindow();
            WindowManager.LayoutParams layoutParams = window.getAttributes();
    
            layoutParams.alpha = 0.9f;
            layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
            layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            window.setAttributes(layoutParams);
    
            DisplayMetrics dm = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(dm); //获取屏幕的宽高
            window.setLayout((int) (dm.widthPixels * 0.85), ViewGroup.LayoutParams.WRAP_CONTENT);
    
    
            window.setGravity(Gravity.BOTTOM);
    //        window.setGravity(Gravity.CENTER);  // 显示的位置
            window.setBackgroundDrawable(null);
            window.setWindowAnimations(R.style.myDialogAnimation);  //底部弹出动画
    
            View view = LayoutInflater.from(this).inflate(R.layout.dialog_bottom_profile, null);
            window.setContentView(view);
    
            View unFollowBtn = view.findViewById(R.id.profile_dialog_un_follow);
            View cancelBtn = view.findViewById(R.id.profile_dialog_cancel);
        }
        <style name="myDialogAnimation" parent="Theme.AppCompat.Dialog">
            <item name="android:windowEnterAnimation">@anim/pop_show_anim</item>
            <item name="android:windowExitAnimation">@anim/pop_hidden_anim</item>
        </style>
    

      pop_show_anim.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:duration="300"
            android:fromYDelta="100%"
            android:toYDelta="0%"
    
            android:fromXDelta="0%"
            android:toXDelta="0%"
            />
    
        <alpha
            android:duration="300"
            android:fromAlpha="0.0"
            android:toAlpha="1.0" />
    </set>

    pop_hidden_anim.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
    
        <translate
            android:duration="300"
            android:fromYDelta="0"
            android:toYDelta="100%" />
        <alpha
            android:duration="300"
            android:fromAlpha="1.0"
            android:toAlpha="1.0" />
    </set>
  • 相关阅读:
    jqGrid 属性、事件全集
    把app(apk和ipa文件)安装包放在服务器上供用户下方法
    c#中如何获取本机MAC地址、IP地址、硬盘ID、CPU序列号等系统信息
    Visual Studio Installer打包安装项目VS2015
    小白入门服务器压测
    PHP正则表达式快速查找
    PHP创建创建资源流上下文实现携带cookie访问
    js中文转Unicode编码与解码
    PHP的fpm配置学习笔记
    微信公众号PHP生成二维码海报的几个小扩展
  • 原文地址:https://www.cnblogs.com/huyang011/p/7481741.html
Copyright © 2020-2023  润新知