【问题标题】:Is there any way to set native AlertDialog corner radius using only styles.xml with no extra code?有没有办法只使用styles.xml 设置本机AlertDialog 角半径而无需额外代码?
【发布时间】:2019-09-26 23:45:57
【问题描述】:

我想知道有什么方法可以实现吗?问题只是关于 styles.xml 代码修改,而不是使用自定义布局以编程方式制作自定义对话框。

【问题讨论】:

  • 我认为它的默认半径可能没有我们在 Material Card View 中看到的属性..并且严格保持设计标准很好。如果你愿意,你可以创建一个自定义...
  • 我认为这应该是一种通过深入挖掘样式来实现它的方法。是的,我知道用材料设计跟上一切都是一个好习惯,但有时这取决于客户的意愿而不是开发人员:)

标签: android material-design android-alertdialog material-components-android material-components


【解决方案1】:

您可以使用Material ThemeshapeAppearanceOverlay 属性的AlertDialog 组件中的customize the shape

类似:

  <!-- Alert Dialog -->
  <style name="MyThemeOverlayAlertDialog" parent="@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MyApp.Dialog.Rounded</item>
  </style>

  <style name="ShapeAppearanceOverlay.MyApp.Dialog.Rounded" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">8dp</item>
  </style>

需要材料组件库1.1.0版本。

【讨论】:

    猜你喜欢
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 2016-10-12
    • 2021-06-12
    相关资源
    最近更新 更多