Android Anko警报文本颜色显示错误
我正在显示带有消息和ok按钮的警报对话框。但ok按钮的颜色和按钮的文字是一样的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 {
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谢谢你的帮助。实际上,问题在于新的材料样式。我把它取了下来,它工作得很好。