基本上我想做opposite of this:在我自己之上运行另一个活动(我没有写),并使该活动透明化。所以它就像运行另一个应用程序(无论它可能是什么),但具有自定义背景。
答案 0 :(得分:1)
您不能影响其他活动的背景。
因此,除非您未编写的其他活动已经透明,或者为其他活动提供某种类型的API以使其变得透明(可能但不太可能)。你真的没办法实现这个目标。
答案 1 :(得分:1)
我需要相反的方式。我有一个活动,我打电话给另一个应用程序。但有时我会为用户提供一些信息。所以我会将透明的Activity混合到另一个App上。
我仍然这样做。我用透明的背景做了一个活动。当我调用此活动时,它将被打开。但不是在其他App面前。我的主要活动将被打开,并且透明的活动将开始。
但我喜欢在另一个应用程序面前看到我的透明活动。这可能吗?
我的代码:
public class MsgDialog extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.msg_dialog);
}
}
这是迄今为止没有功能的活动,但这不重要。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:background="@color/transparent ">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
布局仅限2个按钮,但透明背景。
<activity android:name=".MsgDialog" android:theme="@style/Theme.Transparent"></activity>
此活动的清单行:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
我自己的主题资源
所以它可以工作,但只能在我自己的应用程序前面,而不是在外国应用程序面前。 任何理想的解决我的问题?
由于 Oner