[英]How can I not disable background interaction when alertdialog is shown in android
How can I not disable background interaction when the alertdialog is showing?显示警报对话框时如何不禁用后台交互? While keeping the alertdialog on the screen Note that I use activity to display it like an alertdialog.
将警报对话框保留在屏幕上请注意,我使用活动来显示它,就像警报对话框一样。
Summary概括
I wanna make the screen touchable when the alertdialog is showing.我想在显示警报对话框时使屏幕可触摸。 And is there a way to do this from the manifest.xml folder?
有没有办法从 manifest.xml 文件夹中做到这一点?
maybe this can help也许这可以帮助
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setCancelable(false);
I don't think you can do that with alert dialog.我认为您不能通过警报对话框来做到这一点。 In one of my recent project I needed the same feature (A pop up where the outside element can be clicked even when pop up is shown).
在我最近的一个项目中,我需要相同的功能(即使显示弹出窗口,也可以单击外部元素的弹出窗口)。
The workaround was that I created a Relative Layout (Holding Views of my alert dialog) and put it inside root layout which was also a relative layout.解决方法是我创建了一个相对布局(保持我的警报对话框的视图)并将其放在根布局中,这也是一个相对布局。
Initially visibility of inside relative layout was set to Gone
.最初内部相对布局的可见性设置为
Gone
。 And I was just controlling the visibility of inside relative layout on button click.我只是控制按钮单击时内部相对布局的可见性。 And When the pop up was being displayed, I was still able to click the element outside of inside relative layout.
并且当显示弹出窗口时,我仍然可以单击内部相对布局之外的元素。
One important thing, You need to set android:elevation="20dp"
to your inside relative layout in order to overlap and get the pop-up.一件重要的事情,您需要将
android:elevation="20dp"
设置为您的内部相对布局,以便重叠并获得弹出窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.