Android N: ProgressDialog 和 AlertDialog 显示问题

Android N: ProgressDialog and AlertDialog display issue

问题:

我在应用程序的多个位置使用了 AlertDialogProgressDialog。它们在 Android 版本低于 Android N 预览时显示良好。但是,当我使用 Android N Preview(Nexus 5X 上的 NDP3)对其进行测试时,半透明背景似乎并没有覆盖整个屏幕。

AndroidN:对话框的半透明背景不覆盖整个屏幕

这就是我在 activity:

中创建对话框的方式
public static void showDialog(final Activity activity, final String title, final String message, final String positiveButtonText, final String negativeButtonText, final DialogInterface.OnClickListener positiveButtonListener, final DialogInterface.OnClickListener negativeButtonListener, final Boolean cancellable) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            AlertDialog.Builder alert = new AlertDialog.Builder(activity);
            alert.setTitle(title);
            alert.setMessage(message);
            alert.setPositiveButton(positiveButtonText != null ? positiveButtonText : activity.getString(R.string.button_text_ok), positiveButtonListener);
            alert.setNegativeButton(negativeButtonText != null ? negativeButtonText : activity.getString(R.string.button_text_cancel), negativeButtonListener);

            if (cancellable != null) {
                alert.setCancelable(cancellable);
            } else {
                alert.setCancelable(false);
            }

            //creating an alert dialog from our builder.
            alertDialog = alert.create();
            if (!activity.isFinishing() && alertDialog != null) {
                alertDialog.show();
                alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(activity, android.R.color.black));
                alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(activity, android.R.color.black));
            }
        }
    });
}

这里是 activity 主题:

<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

<!-- Base application theme. Include the items here which are common to all version. -->
<style name="AppTheme.Base" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!--Customize Action Bar-->
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowActionBar">true</item>
    <item name="actionBarStyle">@style/Theme.TradeRev.ActionBar</item>
    <item name="android:actionBarStyle">@style/Theme.TradeRev.ActionBar</item>
    <item name="colorPrimary">@color/light_green</item>
    <item name="colorPrimaryDark">@color/green_title_bar</item>
    <item name="colorAccent">@android:color/white</item>
    <item name="actionMenuTextColor">@android:color/white</item>
    <item name="android:actionMenuTextColor">@android:color/white</item>
    <item name="android:homeAsUpIndicator">@drawable/button_back_up_navigation</item>

    <!-- Title Text Color -->
    <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>
</style>

问题:

这是 Android N 的问题还是 API 中的某些内容发生了变化,我们需要为 Android N 及更高版本合并?

这是 N DP 中的一个已知问题。参见 https://code.google.com/p/android/issues/detail?id=205765

这是一个平台问题。您无需在您的应用中解决此问题。