透明な画面を作成する
大手が作成するアプリには操作説明として通常の画面の上に
操作説明が表示されることがある。
アプリでさきのような操作説明画面を表示したい場合は、
透明なActivityを作成して透明な画面を本来の画面の手前に配置するとよい。
方法
AndroidManifest.xml の
android:theme="@android:style/Theme.Translucent"
を追加すればよい。
タイトルバーを非表示にしたい場合は
android:theme="@android:style/Theme.Translucent.NoTitleBar"
を使用する
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.clearactivitysample" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.clearactivitysample.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
半透明の画面を作成する
styles.xml
<drawable name="translucent_background">#44FF0000</drawable> <style name="Theme.MyTrans" parent="android:style/Theme.Translucent.NoTitleBar"> <item name="android:windowBackground">@drawable/translucent_background</item> </style>
AndroidManifest.xml
<activity android:name="com.example.clearactivitysample.MainActivity" android:label="@string/app_name" android:theme="@style/Theme.MyTrans" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>