透明、浮动的 Android Activity 不允许更新其背后的内容
我已经尝试并试图让一个透明的浮动活动显示(作为覆盖),但允许其后面的任何内容仍然显示和更新。现在看来,如果我后面的 Activity 关闭或打开一个新的 Activity(在这种情况下可能是其中之一),则新的 Activity 不会通过我的 Activity 照射到用户。
我已经尝试了我能想到的所有标志组合,目前我假设标志不是答案。谁能帮我找到正确的代码来完成这样的事情?
在有人问之前,我有一个此类活动的有效用例;不,我不想用它来惹恼用户。
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 Activity 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,这是不可能的。应该可以使用主题 Theme.Dialog 或 Theme.Translucent 创建活动(请参阅 http://developer.android.com/guide/topics/ui/themes.html)使其下方的任何活动仍然至少部分显示。问题是,下面的 Activity 将被暂停(它的 onPause 将被触发,但它的 onStop 将不会),并且我不相信以任何方式让它运行任何代码。
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.
我还没有研究过如何制作透明的 Activity,但我认为以 Activity 的方式不可能做到这一点。这似乎是合乎逻辑的,因为即使你有一个透明的 Activity,它仍然依赖于其中的 View - View 构成透明部分,不是
活动
。这意味着您最终可能会得到一个透明的View
。如果您有一个带有透明
View
的“前”Activity
和一个“后”Activity
,则“后”Activity< /code> 对用户不可见 - 这是因为您处于另一个
Activity
中。所以,正确的方法是使用透明的
View
。I have not investigated in making a transparent
Activity
but I don't think it's possible in anActivity
way. This seems to be logical since even if you have a transparentActivity
it's still relying on theView
inside it - theView
makes the transparent part, not theActivity
. This means you're probably gonna end up with a transparentView
instead.If you have a "front"
Activity
with a transparentView
and then a "back"Activity
, the "back"Activity
would not be visible to the user - and that's because you're in anotherActivity
.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.