首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何像Google Photos App中那样自定义提醒对话框按钮

如何像Google Photos App中那样自定义提醒对话框按钮
EN

Stack Overflow用户
提问于 2019-01-02 18:38:04
回答 3查看 156关注 0票数 0

如何实现如下的报警对话框按钮样式:

我是否必须创建一个自定义的“对话框”,或者这可以通过AlertDialog主题来实现?

EN

回答 3

Stack Overflow用户

发布于 2019-01-02 20:36:20

您可以自定义对话框屏幕,就像创建正常活动屏幕一样,但您可以搜索不同的对话框屏幕,尝试使用this库。

票数 0
EN

Stack Overflow用户

发布于 2019-01-02 21:31:09

你应该使用这个库来创建漂亮的对话框

https://github.com/pedant/sweet-alert-dialog

票数 0
EN

Stack Overflow用户

发布于 2019-09-22 04:17:21

只需使用自定义样式的即可:

代码语言:javascript
运行
复制
  new MaterialAlertDialogBuilder(MainActivity.this, 
            R.style.MyThemeOverlay_MaterialComponents_MaterialAlertDialog)
              .setTitle("Keep backup off?")
              .setMessage("Backup is free and unlimited at high quality")
              .setPositiveButton("Turn on", null)
              .setNegativeButton("Keep off", /* listener = */ null)
              .show();

使用buttonBarPositiveButtonStylebuttonBarNegativeButtonStyle属性更改默认颜色。

在这种情况下,可以为正按钮使用filled button (Widget.MaterialComponents.Button),为负按钮使用Text Button (Widget.MaterialComponents.Button.TextButton.Dialog)。

代码语言:javascript
运行
复制
  <style name="MyThemeOverlay.MaterialComponents.MaterialAlertDialog" parent="@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">

    <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
    <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
  </style>

  <style name="PositiveButtonStyle" parent="@style/Widget.MaterialComponents.Button">
    <item name="android:textColor">#FFFFFF</item>
    <item name="backgroundTint">@color/primaryDarkColor</item>
  </style>

  <style name="NegativeButtonStyle" parent="@style/Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">@color/primaryDarkColor</item>
  </style>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54004813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档