透明、浮动的 Android Activity 不允许更新其背后的内容

发布于 2024-11-02 11:48:56 字数 245 浏览 8 评论 0原文

我已经尝试并试图让一个透明的浮动活动显示(作为覆盖),但允许其后面的任何内容仍然显示和更新。现在看来,如果我后面的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡看悲欢离合 2024-11-09 11:48:56

据我所知,这是不可能的。应该可以使用主题 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.

一身骄傲 2024-11-09 11:48:56

我还没有研究过如何制作透明的 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 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.

温柔女人霸气范 2024-11-09 11:48:56

可以通过在其上实现广播接收器并在需要时发送广播来更新下面的活动。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文