开发者

Transparent, floating Android Activity doesn't allow updates to content behind it

I have tried and tried to get a transparent, floating Activity to show up (as an overlay), but allow whatever is behind it to still show AND update. Right now it seems that if the Activity behind mine is closed or a new one opens (could be either in this case), the new underneath Ac开发者_开发知识库tivity does not shine through my Activity to the user.

I have tried every combination of Flags I can come up with, and at this point I'm assuming Flags are not the answer. Can anyone help me find the proper code to do such a thing?

Before anyone asks, I have a valid use case for this type of Activity; no, I don't plan to annoy the user with it.


As far as I know, this is not possible. It should be possible to create an activity using the theme Theme.Dialog or Theme.Translucent (see http://developer.android.com/guide/topics/ui/themes.html) to have whatever activity is beneath it still show at least partially. The problem is, is that the Activity below will be Paused (it's onPause will have fired, but it's onStop will not have) and I don't believe it is possible in any way to have it run any code.


I have not investigated in making a transparent Activity but I don't think it's possible in an Activity way. This seems to be logical since even if you have a transparent Activity it's still relying on the View inside it - the View makes the transparent part, not the Activity. This means you're probably gonna end up with a transparent View instead.

If you have a "front" Activity with a transparent View and then a "back" Activity, the "back" Activity would not be visible to the user - and that's because you're in another Activity.

So, the correct way is to use a transparent View.


It is possible to update the activity below by implementing a Broadcast receiver on it, and sending Broadcasts from whenever you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜