Can we interact with background activity when displaying a dialog over it in android

后端 未结 4 1635
深忆病人
深忆病人 2021-01-21 08:12

I want to display a dialog over an activity but still want to interact with background activity to perform something, while the dialog is being displayed. How can this be done?

4条回答
  •  耶瑟儿~
    2021-01-21 09:01

    I've found a pretty neat work around for this problem. If you place a transparent view on top of everything you can implement a callback to inject an event into the underlying view, but it doesn't have to be an event it can be any code you want to execute on the background view. I have an open source library that demonstrates this. If you check out my repo at: https://bitbucket.org/warwick/hgdialrepo you will find that this library comes with a demo application. Within this demo app you will find a cog demo. If you examine the code behind the cog demo you will see how this can be achieved.

提交回复
热议问题