英文:
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();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论