问题描述
我有一个使用 Theme.Dialog 样式的活动,因此它是另一个活动的浮动窗口.但是,当我在对话框窗口外(在后台活动上)单击时,对话框将关闭.我怎样才能阻止这种行为?
I have an activity that is using the Theme.Dialog style such that it is a floating window over another activity. However, when I click outside the dialog window (on the background activity), the dialog closes. How can I stop this behaviour?
推荐答案
这可以帮助您.这是一种处理触摸外部事件的方法:
This could help you. It is a way to handle the touch outside event:
通过捕捉事件而不做任何事情,我认为您可以防止关闭.但奇怪的是,您的活动对话框的默认行为应该是不在您触摸外部时自行关闭.
By catching the event and doing nothing, I think you can prevent the closing. But what is strange though, is that the default behavior of your activity dialog should be not to close itself when you touch outside.
(PS:代码使用的是WindowManager.LayoutParams)
(PS: the code uses WindowManager.LayoutParams)
这篇关于防止 Android 活动对话框在外部触摸时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!