简体   繁体   English

android 2活动在同一屏幕上

[英]android 2 activities on the same screen

I've a tabBar with 4 tabs, the Main tab is the first one, and when I click the second one I want do display another activity above the main activity in the half of the screen, reducing the opacity of the main. 我有一个带有4个标签的tabBar,Main标签是第一个标签,当我单击第二个标签时,我想在屏幕的一半上方的main活动上方显示另一个活动,以减少main的不透明度。 I'm doing this with a Dialog but it's not the result I want. 我正在使用对话框执行此操作,但这不是我想要的结果。 What are the best way to do this? 最好的方法是什么?

example image 示例图片

http://s9.postimg.org/e24pqpl3z/Untitled.jpg

看一下Fragments ,这似乎是使用它们的最佳时机。

There are only 3 options to achieve what you want. 只有3种选择可实现您想要的。

  • Second activity can be dialog (You already said you do it but you don't like). 第二个活动可以是对话(您已经说过做到了,但是您不喜欢)。
  • Using fragments . 使用片段 (recommended) (推荐的)
  • Using layouts by playing with visibility, (not recommended in your case) 通过发挥可见性来使用布局(不建议您这样做)

A Fragment represents a behavior or a portion of user interface in an Activity. 片段表示活动中的行为或用户界面的一部分。 You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities 您可以在一个活动中组合多个片段以构建多窗格UI,并在多个活动中重用一个片段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM