6

I'm using: android:theme="@android:style/Theme.Translucent.NoTitleBar"

in combination with: getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

to get a nice transparent background blur effect, emulates a dialog style.

This works great on 2.3 and down, but it is a solid color(read not transparent) on devices running ICS / 3.0 and up. I know they introduced a holo theme and there does not seem to be a specific Theme.Holo.Translucent theme. Any ideas on how to get a translucent background on both ICS and older, I'm not opposed to using separate themes defined in values-v11.

AakashM
  • 62,551
  • 17
  • 151
  • 186
sgarman
  • 6,152
  • 5
  • 40
  • 44
  • Does not look like this will solve your issue but in case you missed it: [Holo everywhere](http://android-developers.blogspot.com/2012/01/holo-everywhere.html) – tidbeck Jan 10 '12 at 00:42
  • Could you specify what devices are running on? Does Theme.Translucent.NoTitleBar work for you in a newly created, minimal Android project? Does android:hardwareAccelerated true/false make a difference? Does various combinations of attributes in the tag make a difference (i.e. different compatibility modes)? – Martin Nordholts Jan 11 '12 at 08:30
  • 1
    Just made a new project with minimal manifest (auto generated) and added the theme. Works on my 2.3 devices but not on the Galaxy Nexus. android:hardwareAccelerated does not seem to impact it or uses-sdk. – sgarman Jan 11 '12 at 19:23

2 Answers2

3

Use

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); 

or extend Theme.Translucent.NoTitleBar and add

<item name="android:windowBackground">@android:color/transparent</item>
Zsolt Safrany
  • 13,290
  • 6
  • 50
  • 62
1

It seems they deprecated blurring, at least with FLAG_BLUR_BEHIND:

public static final int FLAG_BLUR_BEHIND

This constant is deprecated. Blurring is no longer supported.

Community
  • 1
  • 1
aromero
  • 25,681
  • 6
  • 57
  • 79
  • Good find, but even if I remove that I still don't get the transparency from the theme. So while this is a good tip, it does not actually solve my issue :( – sgarman Jan 07 '12 at 00:46