MaterialComponents主题警报对话框按钮 [英] MaterialComponents theme alert dialog buttons
问题描述
最近我从支持库切换到com.google.android.material:material:1.0.0
但是现在我有一个问题,在此页面中有一条注释
我正在使用的主题 完全按照该注释中的说明进行操作,它将AlertDialog Buttons替换为MaterialButtons,但是问题是默认情况下MaterialButtons是彩色背景,现在这些按钮看起来像这样: >
如何使它们再次变得无边界和无背景? PS我正在使用警报生成器来创建警报对话框:
我知道是什么导致了此问题.我需要使用其他AlertDialog类: 当我切换到这一步时,一切都按预期开始工作.这是我找到解决方案的地方: https://github.com/material-components/material- components-android/issues/162 Recently I switched from support library to com.google.android.material:material:1.0.0 But now I have a problem, in this pages there's a note https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md Note: Using a Material Components theme enables a custom view inflater which replaces default components with their Material counterparts. Currently, this only replaces Button XML components with MaterialButton. And the theme I am using does exactly what it says in that note, it replaces AlertDialog Buttons to MaterialButtons but the problem is that by default MaterialButtons are colored background and now the buttons looks like this: How can I make them borderless and backgroundless again? PS I am using alert builder to create alert dialogs:
I figured out what was causing this problem. I need to use different AlertDialog class: When I switched to this everything started working as expected. Here's where I found the solution: https://github.com/material-components/material-components-android/issues/162 这篇关于MaterialComponents主题警报对话框按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!Theme.MaterialComponents.Light.NoActionBar
android.app.AlertDialog.Builder
androidx.appcompat.app.AlertDialog
Theme.MaterialComponents.Light.NoActionBar
android.app.AlertDialog.Builder
androidx.appcompat.app.AlertDialog