将一个活动覆盖在另一个活动上或将一个视图覆盖在另一个活动上 [英] Overlay an activity on another activity OR overlay a view over another
问题描述
我有 2 个类,FirstActivity 和 SecondActivity.
I have 2 classes, FirstActivity and SecondActivity.
第一个活动
Intent intent=new Intent(getApplicationContext(),SecondActivity.class);
startActivity(intent);
SecondActivity 是否可以叠加在 FirstActivity 上?IE.FirstActivity 变暗,SecondActivity 显示在 FirstActivity 之上.
Is it possible for SecondActivity to overlay on FirstActivity? ie. FirstActivity gets dimmed, SecondActivity gets displayed on top of FirstActivity.
如果不能用于 2 个不同的活动,是否可以在同一活动中为 2 个视图进行叠加?我希望使用对话框不是唯一的选择.
If it is not possible for 2 different activities, is it possible to do an overlay for 2 views in the same activity? I hope using dialog is not the only option.
推荐答案
我建议您将第二个 Activity 设置为对话框——这会使背景变暗.这是一个可能有用的教程:
I suggest you set your second activity up as a dialog -- which will dim the background. Here is a tutorial that could be helpful:
http://developer.android.com/guide/topics/ui/对话框.html
http://www.helloandroid.com/教程/how-display-custom-dialog-your-android-application
或者您可以简单地将清单中的主题设置为您的 SecondActivity 的对话框.
Or you can simply set the theme in the manifest as a dialog for your SecondActivity.
这篇关于将一个活动覆盖在另一个活动上或将一个视图覆盖在另一个活动上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!