Как изменить цвет элемента диалога с черного на белый? - PullRequest
0 голосов
/ 04 августа 2020

Я использую следующую тему для своего диалога:

<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textColorSecondary">@color/colorWhite</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:background">@color/colorPrimary</item>
    <item name="android:textColor">@color/colorWhite</item>
    <item name="android:textColorAlertDialogListItem">@color/colorWhite</item>
</style>

Все работает, кроме цвета текста элемента. Мне нужно быть белым, но почему-то так и осталось. Как я могу сделать этот текст белым? Спасибо

enter image description here

Edit:

Here is my AppTheme:

 @ color / colorPrimary  @ color / colorPrimaryDark  @ color / colorAccent  @ цвет / цвет Белый   

Ответы [ 2 ]

1 голос
/ 05 августа 2020

Вы можете сослаться на Тема AlertDialog: Как изменить цвет текста элемента?

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="textColorAlertDialogListItem">@color/colorWhite</item>
</style>

или

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@style/AlertDialogStyle </item>
</style>

<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    ...
    <item name="textColorAlertDialogListItem">@color/colorWhite</item>
    <!--
    <item name="android:textColor">@color/colorWhite</item>
    -->
</style>

Также вы можете изменить android: textColor, но он изменит цвет всего текста в диалоговом окне

0 голосов
/ 04 августа 2020

Используйте свой собственный стиль DialogBox при создании DialogBox.

new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogStyle))

Добавьте эти строки в тему вашего приложения

<item name="android:alertDialogTheme">@style/AlertDialogStyle</item>
<item name="android:alertDialogStyle">@style/AlertDialogStyle</item>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...