Однако в некоторых темах приложений текст кнопки диалогового окна использует colorPrimary.
Вот мои выводы:
Theme.AppCompat.Light.DarkActionBar — текст кнопки диалогового окна использует colorAccent

Theme.MaterialComponents.DayNight.DarkActionBar — в тексте кнопки диалогового окна используется colorPrimary
[img]https://i.stack. imgur.com/GKpLY.png[/img]
Theme.Material3.DayNight.NoActionBar — текст кнопки диалогового окна использует colorPrimary

Мне интересно, как я могу обеспечить использование colorAccent для текста кнопки диалогового окна, независимо от темы приложения.
Вот код тестирования, который я использую:
themes.xml
#ff0000
#ff1778f2
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
showDialog()
}
private fun showDialog() {
val builder = AlertDialog.Builder(this)
builder.setTitle("Confirmation")
builder.setMessage("Do you want to proceed?")
// Add OK button
builder.setPositiveButton("OK") { dialog, which ->
// Handle OK button click here
}
// Add Cancel button
builder.setNegativeButton("Cancel") { dialog, which ->
// Handle Cancel button click here
dialog.dismiss()
}
// Create and show the AlertDialog
val alertDialog = builder.create()
alertDialog.show()
}
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... app-themes
Мобильная версия