Mis*_*rdi 5 android android-alertdialog material-design material-components-android androidx
这是我的根风格:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
Run Code Online (Sandbox Code Playgroud)
这是我创建对话框的方式:
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return AlertDialog.Builder(requireActivity())
.apply {
setMessage(R.string.dialog_delete_service_message)
setPositiveButton(
R.string.dialog_delete_service_positive_button
) { _, _ ->
listener?.onConfirmed()
}
setNegativeButton(R.string.dialog_delete_service_negative_button, null)
}.create()
}
Run Code Online (Sandbox Code Playgroud)
片段是 的子类androidx.fragment.app.DialogFragment。
以下是对话框的显示方式:
我想显示无边框按钮,但对话框按钮有边框。是否缺少任何样式?
new MaterialAlertDialogBuilder(context)
.setTitle("xxxx")
.setMessage("...")
.setPositiveButton("..", null)
.show();
Run Code Online (Sandbox Code Playgroud)
并在您的应用主题中使用此样式:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
...
<item name="materialAlertDialogTheme">@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
323 次 |
| 最近记录: |