设置固定大小弹窗

private void showGameCoinDialog(int coins) {
        // 获取LayoutInflater实例
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

        // 使用LayoutInflater加载弹窗布局
        View popupView = inflater.inflate(R.layout.game_coin, null);

        // 创建PopupWindow实例并设置宽度和高度
        final PopupWindow popupWindow = new PopupWindow(popupView,
                ViewGroup.LayoutParams.MATCH_PARENT, // 宽度 (全屏)
                ViewGroup.LayoutParams.MATCH_PARENT, // 高度 (全屏)
                true); // 设置弹窗可聚焦
        popupWindow.setClippingEnabled(false); // 禁用裁剪,使弹窗覆盖状态栏
        

        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                // 在弹窗消失后重新设置全屏模式
                hideSystemUI();
            }
        });

        // 显示弹窗后,隐藏系统UI
        popupWindow.setFocusable(true);
        popupWindow.update();
        // 设置点击外部区域关闭弹窗
        popupWindow.setOutsideTouchable(true);

        // 显示弹窗
        View parentView = findViewById(android.R.id.content); // 替换为你需要的父视图
        popupWindow.showAtLocation(parentView, Gravity.CENTER, 0, 0);

        hideSystemUI();

        TextView closeButton = popupView.findViewById(R.id.back);
        TextView money_size  = popupView.findViewById(R.id.money_size);

        closeButton.setOnClickListener(v -> popupWindow.dismiss());
        money_size.setText(String.valueOf(coins));

        ImageView icon_bg = popupView.findViewById(R.id.icon_bg);
        // 设置旋转动画,围绕中心点旋转360度
        ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(icon_bg, "rotation", 0f, 360f);
        rotateAnimation.setDuration(5000);  // 动画持续时间,单位为毫秒
        rotateAnimation.setRepeatCount(ObjectAnimator.INFINITE);  // 无限循环
        rotateAnimation.setInterpolator(new LinearInterpolator()); // 设置匀速插值器

        // 开始动画
        rotateAnimation.start();

    }

设置全屏弹窗,并且隐藏状态栏

private void showGameCoinDialog(int coins) {
        // 获取LayoutInflater实例
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

        // 使用LayoutInflater加载弹窗布局
        View popupView = inflater.inflate(R.layout.game_coin, null);

        // 创建PopupWindow实例并设置宽度和高度
        final PopupWindow popupWindow = new PopupWindow(popupView,
                ViewGroup.LayoutParams.MATCH_PARENT, // 宽度 (全屏)
                ViewGroup.LayoutParams.MATCH_PARENT, // 高度 (全屏)
                true); // 设置弹窗可聚焦
        popupWindow.setClippingEnabled(false); // 禁用裁剪,使弹窗覆盖状态栏

        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                // 在弹窗消失后重新设置全屏模式
                hideSystemUI();
            }
        });

        // 显示弹窗后,隐藏系统UI
        popupWindow.setFocusable(true);
        popupWindow.update();
        // 设置点击外部区域关闭弹窗
        popupWindow.setOutsideTouchable(true);

        // 显示弹窗
        View parentView = findViewById(android.R.id.content); // 替换为你需要的父视图
        popupWindow.showAtLocation(parentView, Gravity.CENTER, 0, 0);

        hideSystemUI();

        TextView closeButton = popupView.findViewById(R.id.back);
        TextView money_size  = popupView.findViewById(R.id.money_size);

        closeButton.setOnClickListener(v -> popupWindow.dismiss());
        money_size.setText(String.valueOf(coins));

        ImageView icon_bg = popupView.findViewById(R.id.icon_bg);
        // 设置旋转动画,围绕中心点旋转360度
        ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(icon_bg, "rotation", 0f, 360f);
        rotateAnimation.setDuration(5000);  // 动画持续时间,单位为毫秒
        rotateAnimation.setRepeatCount(ObjectAnimator.INFINITE);  // 无限循环
        rotateAnimation.setInterpolator(new LinearInterpolator()); // 设置匀速插值器

        // 开始动画
        rotateAnimation.start();

    }

    //弹窗隐藏状态栏
    private void hideSystemUI() {
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(uiOptions);
    }