【问题标题】:Material Dialog Change Text Sizes材质对话框更改文本大小
【发布时间】:2019-09-11 15:04:27
【问题描述】:

我想使用styles.xml 文件中的自定义样式为使用MaterialAlertDialogBuilder 创建的材料警报对话框自定义标题、描述和按钮字体大小。但是,我不确定如何创建样式。有人可以帮我解决这个问题。 TIA

【问题讨论】:

  • 你给的链接没有使用材质主题。我的对话框使用材料主题,因此不是相同的类。我尝试了为没有材料主题的对话框提供的解决方案,但它们不起作用。

标签: android material-design


【解决方案1】:
AlertDialog dialog = new MaterialAlertDialogBuilder(this)
                .setMessage(description)
                .setCancelable(false)
                .setPositiveButton(R.string.ok, null)
                .create();

        dialog.show();

        dialog.getButton(Dialog.BUTTON_POSITIVE).setTextSize(18);

        TextView textView = dialog.findViewById(android.R.id.message);
        if (textView != null) {
            textView.setTextSize(18);
        }

【讨论】:

    猜你喜欢
    • 2019-03-24
    • 2021-02-16
    • 1970-01-01
    • 2017-11-02
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    相关资源
    最近更新 更多