views:

74

answers:

1

Hey! I have a SlidingDrawer in my application. When it opens, I want everything underneath it to be blurred. Anyway I can do this? Thanks.

+1  A: 

The "BLUR_BEHIND" setting is a window feature you can only set at the window/activity level currently. Unless you want to have your sliding drawer encompass a whole activity (which doesn't sound like what you were looking for) I think what you want will be quite difficult to achieve using just the Android API.

Marloke
Are you sure? It'd really give a great look to my app. I have tried meddling around with the onDraw() of Sliding Drawer, but it doesn't seem to have any effect. Do you know why?
Gooner
When you override the onDraw event of a view it allows you to modify how that view is drawn, not the views behind it. You could vie for a translucent view instead (that could be done with on draw or by simply setting the background) but the blurred effect requires the use of lower level code that is not accessible from the API. The only other place I've seen a reference to blur in the API is in the surface object. Unfortunately there's no way for us to set it according to this link: http://groups.google.com/group/android-developers/browse_thread/thread/93f471c48750b813
Marloke
But when I tried to override the onDraw() of SlidingDrawing by extending it into another class, nothing that I drew had any effect on the sliding drawer. Why was that?
Gooner
There are any number of reasons depending on what you wrote, I'd have to see your code to get an idea.
Marloke
Well, I have just extended the SlidingDrawer and created a new MySlidingDrawer. I overrode the onDraw() function, and used canvas.drawRect(), to draw a rectangle with the color red(specified in the paint object). But the SlidingDrawer was as it is. Is onDraw actually called? Thanks.
Gooner
A description of the code isn't really as useful as actual code for debugging I recommend either appending it to your question or starting a new question based on your goals for onDraw(). Is your current goal just to display a translucent background when the drawer is open? If so the easiest way would be to set the color of the layout object being set as the Drawers "content" attribute. you could set its background to something like #55FFFFFF for a translucent white effect (change the lower 6 digits for other colors).
Marloke
Also, keep in mind that when the drawer is open, what displays is the content view inside the drawer, not necessarily the drawer itself.
Marloke
Thanks Marloke, I'll try out you color combination, in the content attribute.So if it was not necessary to specify the content attribute for the drawer, I'd have actually gotten to see the blank drawer?, where my onDraw() would have show me stuff? Also if my content is only a TextView which has it's parameters set to warp_content(both), then I can still see some part of the naked drawer? So that means, my onDraw() must be visible in that portion, right?
Gooner
I haven't had the time to try overriding it myself (and implementing onDraw), but when I tried setting image/color resources to the drawer itself I found that it filled the entire screen space for the drawer whether or not the it was open. (Try setting the drawer's background to white and you'll see what I mean). This leads me to believe that overriding the drawer itself is not particularly useful for what you're trying to do. I recommend sticking to the drawer contents.
Marloke