zoukankan      html  css  js  c++  java
  • 底部对话框

        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>
  • 相关阅读:
    新代(Syntec)机床的IP设置
    使用任务计划程序实现用户未登录情况下的程序开机自启动
    sql server 数据库访问端口配置
    Http请求
    EF
    SQL Server常用处理
    利用ZXing生成条码二维码例子
    SQL JOIN常见情况
    C#ORM框架收集
    sql server连接oracle并实现增删改查
  • 原文地址:https://www.cnblogs.com/huyang011/p/7481741.html
Copyright © 2011-2022 走看看