🔻

android: Activityをpopup表示するときのスタイル設定

に公開

初稿2010/11
#はじめに
Activityをpopup表示するとき、AndroidManifest.xmlに<activity  android:theme="@style/Theme.Dialog">とやると、大体欲しいスタイルになるんですがやはり微調整する。

androidソースツリーのDialogテーマの定義を調べてめぼしい設定を見つけた→ http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/values/themes.xml

下記のような設定を res/values/themes.xmlに書いておき、AndroidManifest.xmlのactivity設定で使う。

  • 設定その1*白枠なしのDialogテーマ
<style name="Theme.NolineDialog" parent = "@android:style/Theme.Dialog">

<item name="android:windowNoTitle">true</item>

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

</style>
  • 設定その2*背景のディマーありのPanelテーマ
<style name="Theme.DimPanel" parent = "@android:style/Theme.Panel">

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

<item name="android:backgroundDimEnabled">true</item>

<item name="android:backgroundDimAmount">0.5</item>

</style>

AndroidManifest.xml

<activity android:name=".popup_test"

android:label="@string/app_name"

android:theme="@style/Theme.NolineDialog">

#参考
http://www.techdoctranslator.com/android/guide/ui/themes

Discussion