首页 > 解决方案 > 在 android 9.0 中打开时对话框闪烁和故障

问题描述

我在 android 9.0 下方单击时打开对话框,在其打开时没有故障或闪烁,但在 android 8.0 下方并在其顺利打开下方。

我试图用下面的方式改变风格,但它也不起作用

<style name="mystyle" parent="@android:style/Theme">
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>



public Dialog displayInPaddedScreenDialog(Context context, View view, DialogInterface.OnDismissListener onDismissListener) {
        Dialog dialog = new Dialog(context, R.style.mystyle);
        dialog.getWindow().getAttributes().windowAnimations = R.style.clubcard_Dialog;
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.copyFrom(dialog.getWindow().getAttributes());
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(lp);
        dialog.setContentView(view);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setOnDismissListener(onDismissListener);
        dialog.show();

        return dialog;
    }

我希望在每个版本的 android 中它都应该顺利打开而不会闪烁或出现故障。

标签: android

解决方案


推荐阅读