【发布时间】:2019-07-05 14:50:12
【问题描述】:
我尝试仅使用 Material Components 中的小部件,但在许多情况下,没有记录如何实现样式。
让我们考虑MaterialAlertDialog。
每次我想显示一个对话框时,我都会调用这部分代码:
MaterialAlertDialogBuilder(context, R.style.Theme_MyApp_Dialog_Alert)
.setTitle("Title")
.setMessage("This is message.")
.setPositiveButton(R.string.ok) { _, _ -> }
.show()
如您所见,我使用的是自定义主题。
<style name="Theme.MyApp.Dialog.Alert" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<!-- attributes here -->
</style>
问题是某些属性不起作用。例如textColor。那么问题来了如何改变MaterialAlertDialog中的body或者title文字颜色?
我使用最新版本的 Material Components - 1.1.0-alpha07。
PS。
我不确定哪个主题应该是父主题。在Material Theme Builder 中,他们使用@style/ThemeOverlay.MaterialComponents.Dialog.Alert,这实际上给出了对话框的“旧”外观。
【问题讨论】:
标签: android android-alertdialog material-components-android material-components