I need to show a custom dialog in my Android application. Standard AlertDialog
design is unacceptable. Android docs say:
Tip: If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in the manifest element:
That's it. The activity now displays in a dialog window instead of fullscreen.
Sounded promising. I did it, but transparency does not work! Background is always grey:
Here is a desc in the manifest:
<activity
android:name=".MyDialogActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Dialog.NoActionBar" >
</activity>
Here is a root of my activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#00000000"
android:layout_width="400dp"
android:layout_height="wrap_content" >
// Content ... //
</RelativeLayout>
I tried also android:background="@null"
- effect was the same.
If I use android:background="#ff0000"
then it's red (as it should be). But how do I make it transparent?
Update
I ended up with
<style name="MyThemeDialogCustom" parent="android:Theme.Holo.Dialog.NoActionBar" >
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
make theme like this
<style name="ThemeDialogCustom">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>