Android:在一个屏幕上查看两个活动

发布于 2024-10-28 22:10:30 字数 300 浏览 3 评论 0原文

我正在寻找同时显示两个活动的最简单方法,以便一个活动始终保持可见,而另一个活动则随着用户交互而变化。

换句话说:

  • 我目前有一个包含多个活动的程序的代码。
  • 用户可以在这些活动之间导航。
  • 我想添加一个新的活动,该活动将始终与我已有的活动一起可见。
  • 当用户从当前 Activity 导航到另一 Activity 时,这个新的“侧面 Activity”将保持可见。

我见过许多不同的想法来做类似的事情,但无法使它们适应我的需要。

任何帮助将不胜感激。

I'm looking for the simplest way to have two activities displayed at once, so that one Activity always remains visible, and the other changes with user interaction.

In other words:

  • I currently have code for a program with several Activities.
  • The user can navigate between these activities.
  • I want to add a new Activity that will always be visible alongside what I already have.
  • When the user navigates from the current Activity to another one, this new "side Activity" will remain visible.

I've seen many different ideas for doing something similar, but haven't been able to adapt them to my needs.

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

dawn曙光 2024-11-04 22:10:30

通过活动,你想要的一切都不可能实现。最接近的是使用主题,以便您的“副活动”在其他非全屏活动后面部分可见。然而,让它在各种屏幕尺寸上正常工作将很困难,并且管理任务堆栈来实现这一点并不让我觉得有什么乐趣。

您应该能够通过正确应用片段来创建类似于您所寻求的东西,但是您最终会得到一个大型活动和一堆片段,而不是一堆活动。

在活动级别,Android 并不是为您寻求的某些持久元素而设计的。

None of what you want is possible with activities. The closest thing is using themes so that your "side activity" is partially visible behind other non-full-screen activities. However, getting this to work properly on a wide range of screen sizes will be difficult, and managing your task stack to pull this off does not strike me as being much fun.

You should be able to create something that resembles what you seek with the proper application of fragments, but you will wind up with one large activity and a bunch of fragments, as opposed to a bunch of activities.

At the activity level, Android is not designed for some persistent element that you seek.

多情出卖 2024-11-04 22:10:30

您可以实现与您想要的类似的东西(就用户所看到的而言)。但它实际上并不是两个正在运行的活动。

检查片段文档。我认为您想使用两个片段:一个位于屏幕顶部,另一个位于底部。

You can achieve something that is similar to what you want (in terms of what the user sees). But it wouldn't be actually two activities running.

Check Fragments Documentation. I think you want to use two fragments: one on the top of the screen and another one on the bottom.

情域 2024-11-04 22:10:30

正如其他人所说,您不能同时在屏幕上显示多个活动。但是,您可以将单独的活动重构为视图,然后显示具有一个持久视图的单个活动以及一组可交换视图(由选项卡或 ViewFlipper 管理)。

Like others have said, you can't have multiple Activities on screen at once. However, you could refactor your separate activities into Views, then show a single Activity with one persistent View alongside a group of swappable Views (managed by tabs or ViewFlipper).

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