我想创建一个弹出窗口。

huangapple go评论62阅读模式
英文:

I want to create a popup

问题

我正在尝试创建一个弹出窗口。

我想要使弹出窗口的背景透明,而边框,因为弹出窗口没有填满页面,要稍微不那么透明,有没有简单的方法可以实现这个?

我尝试过使用一个活动(activity),但是我无法获得我想要的效果,你能帮助我吗?

类似于这样的效果:
我想创建一个弹出窗口。

英文:

I'm trying to create a popup.

I would like to make the background of my popup transparent, and the border, because the popup is not filling the page, a bit more opaque, is there an easy way to do this?

I've tried with an activity but i can't get the effect i want, can you help me?

Something like this:
我想创建一个弹出窗口。

答案1

得分: 0

你可以使用警告对话框来实现这一点,可以在这个链接中了解不同的用法。

还有一个简单的示例如下:

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("警告对话框标题");
builder.setMessage("你的消息");
builder.setNegativeButton("取消", null);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialogInterface, int i) {

    }
});
builder.show();

结果

英文:

You can use Alert Dialogs for this and check this link for different uses

And a simple one like this

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        builder.setTitle("Alert Dialog Title");
        builder.setMessage("Your Message");
        builder.setNegativeButton("No", null);
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
        builder.show();

result

huangapple
  • 本文由 发表于 2020年8月25日 22:35:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63581234.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定