Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Anko警报文本颜色显示错误_Android_Kotlin_Kotlin Android Extensions_Anko - Fatal编程技术网

Android Anko警报文本颜色显示错误

Android Anko警报文本颜色显示错误,android,kotlin,kotlin-android-extensions,anko,Android,Kotlin,Kotlin Android Extensions,Anko,我正在显示带有消息和ok按钮的警报对话框。但ok按钮的颜色和按钮的文字是一样的 context!!.alert ("this test message for the dialog aleat"){ okButton { context!!.toast("yeah it ok") } }.show() 我使用以下代码实现了这一点。为我工作 getContext()?.alert("me") { also {

我正在显示带有消息和ok按钮的警报对话框。但ok按钮的颜色和按钮的文字是一样的

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

我使用以下代码实现了这一点。为我工作

     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>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@样式/自定义警报对话框
@样式/b样式
@android:彩色/白色
@android:彩色/白色

我找到了完美的解决方案:


style.xml中使用
Theme.AppCompat…
而不是
Theme.MaterialComponents…

按钮和文本的样式似乎有问题。我使用了默认样式。您的“colorPrimary”、“colorPrimaryDark”和“colorAccent”是什么“在AppTheme中?使用以下颜色#008577#00574B#D81B60@eurosecom谢谢你的帮助。实际上,问题在于新的材料样式。我把它取了下来,它工作得很好。