我想在另一个活动之上创建一个透明的活动。

我怎样才能做到这一点呢?


当前回答

它是这样的:

<activity android:name=".usual.activity.Declaration" android:theme="@android:style/Theme.Translucent.NoTitleBar" />

其他回答

把它放在style.xml中

<item name="android:windowBackground">@android:color/transparent</item>

或在清单中添加

<activity android:name=".usual.activity.Declaration" 
 android:theme="@android:style/Theme.Translucent.NoTitleBar" />

我发现的最简单的方法是在AndroidManifest中设置活动的主题为android:theme="@android:style/ theme . holo . dialog "。

然后在活动的onCreate方法中,调用getWindow()。setBackgroundDrawable(新ColorDrawable(0));。

它是这样的:

<activity android:name=".usual.activity.Declaration" android:theme="@android:style/Theme.Translucent.NoTitleBar" />

将半透明主题分配给你想要在项目的Android清单文件中透明的活动:

<activity
    android:name="YOUR COMPLETE ACTIVITY NAME WITH PACKAGE"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

所有这些答案可能会让人困惑,透明活动和无UI活动之间是有区别的。

用这个:

android:主题= " @android:风格/ Theme.Translucent.NoTitleBar”

将使活动透明,但将阻塞UI。

如果你想要一个None的UI活动,请使用这个:

android:主题= " @android:风格/主题。NoDisplay”