MaterialComponents 主题警报对话框按钮 [英] MaterialComponents theme alert dialog buttons
问题描述
最近我从支持库切换到 com.google.android.material:material:1.0.0
但现在我有一个问题,在这个页面中有一个注释 >
我怎样才能让它们再次无边界和无背景?
PS 我正在使用警报构建器来创建警报对话框:
android.app.AlertDialog.Builder
我找到了导致这个问题的原因.我需要使用不同的 AlertDialog 类:
androidx.appcompat.app.AlertDialog
当我切换到这个时,一切都开始按预期工作.这是我找到解决方案的地方:
https://github.com/material-components/material-组件-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
Theme.MaterialComponents.Light.NoActionBar
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:
android.app.AlertDialog.Builder
I figured out what was causing this problem. I need to use different AlertDialog class:
androidx.appcompat.app.AlertDialog
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屋!