我的應用程序的主要活動是首選項頁面。這是用戶單擊應用程序圖標時顯示的內容。我還有一項服務,可以發送用戶狀態欄通知,並且可以在屏幕上顯示半透明覆蓋圖。我遵循this發佈創建我的透明活動,所有這些工作。Android獨立透明活動
問題在於,無論何時,我都會顯示半透明活動,應用程序的主窗口(首選項頁面)在其後面可見。也就是說,半透明覆蓋圖顯示在當前正在運行的任何其他應用程序的頂部。
我該怎麼做才能使半透明活動出現時,我的應用程序中沒有其他活動可見?
這是我的主要活動在AndroidManifest.xml中定義:
<activity android:name=".AppPreferences" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我也有半透明的疊加,它使用從Theme.Translucent派生的自定義主題:
<activity android:name=".AppPopupActivity" android:theme="@style/Theme.SemiTransparent">
<intent-filter>
<action android:name="com.app.HIDE_POPUP"></action>
</intent-filter>
</activity>
這裏是佈局用於半透明覆蓋物:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button android:text="@string/button_done"
android:id="@+id/doneButton"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</RelativeLayout>
</RelativeLayout>
而服務:
<service android:name="AppService">
<intent-filter>
<action android:name="com.app.AppService" />
</intent-filter>
</service>
要顯示透明的活動我運行的服務如下:
Intent intent = new Intent(this, AppPopupActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
感謝您的幫助
這不就是透明的定義是什麼?你可以看到它背後的任何東西。 – nhaarman
我同意尼克,你沒有提到你想要發生什麼。 – dmon
你們都錯了,(我想)這個人有他的活動堆棧的問題,什麼擺脫所有的堆棧,並推出他的透明的東西;-) 查看答案。 –