试图复制默认操作对话框按钮

Trying to replicate default action dialog buttons

我已经创建了一个自定义操作对话框,但是对于按钮,我想复制默认的 Android 按钮,但似乎无法正确设置。

有没有办法检查默认的文本大小、字体样式、是否为粗体等?

谢谢

当您扩展 AlertDialog 时,您可以通过调用以下构造函数指定要使用的主题。

protected AlertDialog(@NonNull Context context, @StyleRes int themeResId)

为了复制默认按钮样式,您可以尝试扩展 AppCompat AlertDialog 的默认主题,然后将其传递给您的自定义主题。

<style name="MyCustomAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!-- Optionally you can customize other attributes -->
</style>

-

public class MyCustomAlertDialog extends android.support.v7.app.AlertDialog {
    private MyCustomAlertDialog(Context context) {
        super(context, R.style.MyCustomAlertDialogStyle);
        // ...
    }
}

此站点上有大量信息: https://material.io/design/components/dialogs.html#theming

希望你能找到你要找的东西。