APIサンプル
テーマを使って透明にしています。 背景のボケは getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); で指定
普通
protected void onCreate(Bundle icicle) { // Be sure to call the super class. super.onCreate(icicle); // Have the system blur any windows behind this one. getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); // See assets/res/any/layout/translucent_background.xml for this // view layout definition, which is being set here as // the content of our screen. setContentView(R.layout.translucent_background); }
AndroidManifest.xml - テーマの指定
<activity android:name=".app.TranslucentBlurActivity"
android:label="@string/activity_translucent_blur"
android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
styles.xml - 背景色指定
<!-- Variation on our application theme that has a transparent
background; this example completely removes the background,
allowing the activity to decide how to composite. Also here we
force the translucency ourself rather than making use of the built-in
translucent theme. -->
<style name="Theme.Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
<item name="android:windowBackground">@drawable/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
完全に透明
colors.xml
<drawable name="transparent_background">#00000000</drawable>