【问题标题】:how do I round dialog box corners in android studio [duplicate]如何在android studio中圆角对话框[重复]
【发布时间】:2019-02-04 14:51:39
【问题描述】:

刚开始学习android开发,想做一个好看的对话框。

this is what I have right now.

This is how I want it to be.

我尝试查找它,其中大多数都告诉我制作一个新形状并将其添加为对话框背景,但我似乎不明白如何将新形状设置为背景。

这是我的对话框代码:

new AlertDialog.Builder(this)
                .setTitle(" ")
                .setMessage("Congrats! Player " + winner +" wins!")
                .setPositiveButton("Play again", new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //my code here
                    }

                })
                .setNegativeButton("F", null)
                .show();

如何将我的形状背景 xml 链接到此对话框以及如何使正按钮具有屏幕截图中的背景?

编辑:问题已编辑,因为我已经尝试过下面的方法我似乎不理解它,除了它有多个部分(页眉,页脚),我真的不需要我的要求更基本。

【问题讨论】:

标签: java android android-studio android-alertdialog rounded-corners


【解决方案1】:

您可以使用setView(View view) 为您的对话框轻松地为您的AlertDialog 设置自定义视图。

你的代码应该是这样的:

View view = inflater.inflate(R.layout.your_layout_name, null);
new AlertDialog.Builder(this)
                .setView(view)
                .create()
                .show();

【讨论】:

    猜你喜欢
    • 2016-07-18
    • 2013-05-27
    • 1970-01-01
    • 2012-04-11
    • 2020-05-27
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 2021-06-09
    相关资源
    最近更新 更多