Странное всплывающее меню в AlertDialog с настраиваемым стилем фона - PullRequest
0 голосов
/ 27 мая 2020

Как я могу получить всплывающее меню, которое я вижу во всем приложении, иначе (см. Ниже)? Я пробовал поэкспериментировать с popupMenuStyle и popupMenuBackground, но ничего не изменилось.

enter image description here

AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AlertDialogStyle);
...
builder.show();

AlertDialogStyle:

    <style name="AlertDialogStyle" parent="Theme.AppCompat.DayNight.Dialog.Alert">
        <item name="android:windowTitleStyle">@style/DialogTitleStyle</item>
        <item name="android:background">@color/colorPrimary</item>
<!--        <item name="popupMenuStyle">@style/Widget.AppCompat.Light.PopupMenu</item>-->
<!--        <item name="popupMenuBackground">@color/red</item>-->
        <item name="buttonBarNeutralButtonStyle">@style/DialogButtonNeutralStyle</item>
        <item name="buttonBarNegativeButtonStyle">@style/DialogButtonStyle</item>
        <item name="buttonBarPositiveButtonStyle">@style/DialogButtonStyle</item>
    </style>

Если я прокомментирую android:background, всплывающее меню в порядке:

enter image description here

1 Ответ

0 голосов
/ 27 мая 2020

Решено! Вместо использования

<item name="android:background">@color/colorPrimary</item>

в моем собственном стиле я должен был использовать

<item name="android:windowBackground">@color/colorPrimary</item>

enter image description here

...