Неправильное отображение текста оповещения Anko - PullRequest
0 голосов
/ 16 мая 2018

Я показываю диалоговое окно с сообщением и кнопкой ОК. но цвет кнопки ОК и текст кнопки одинаковы

context!!.alert ("this test message for the dialog aleat"){
            okButton { context!!.toast("yeah it ok") }
        }.show()

enter image description here

Ответы [ 2 ]

0 голосов
/ 13 сентября 2018

Я нашел идеальное решение:

Используйте Theme.AppCompat... в styles.xml вместо Theme.MaterialComponents....

0 голосов
/ 31 мая 2018

Я добился этого, используя следующий код.работает для меня

     getContext()?.alert("me") {
            also {
                ctx.setTheme(R.style.CustomAlertDialog)
            }
            okButton {  getContext()!!.toast("Done") }
        }!!.show()

изменения темы

  <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="dialogTheme">@style/CustomAlertDialog</item>
</style>

<style name="CustomAlertDialog" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
  <item name="buttonBarPositiveButtonStyle">@style/btnStyle</item>
    <item name="android:textColor">@android:color/white</item>
</style>

<style name="btnStyle" parent="TextAppearance.AppCompat.Body1">
    <item name="android:textColor">@android:color/white</item>
</style>
...