6

I'm working on a new Android app designed in really flat style. I want to have a DialogAlert that shows up on a blurred background. Effect similiar to the control center on this photo (don't write about NDA, this photo is available on Apple's website):

iOS7

Is it possible? If so, the most important question: how?

M.

Maciej Wilczyński
  • 379
  • 1
  • 5
  • 13
  • 3
    You will likely get bad reviews on the Play Store if your application looks identical (or at least very similar) to iOS 7's flat design. It's OK to spice up your application with your own personal style, of course... but make sure you keep the Android design guidelines in mind and don't use iOS 7's style as a template for your application. :) – Alex Lockwood Aug 26 '13 at 23:29
  • Good question, my designers ask for this kind of thing a lot – CQM Apr 28 '14 at 21:39

4 Answers4

6

Yes this is possible, You have to use something called renderscript. so what you need is bitmap from the view this can be done using the following code.

View v // target view to be blurred
v.setDrawingCacheEnabled(true);
Bitmap screenshot = Bitmap.createBitmap(v.getDrawingCache());

Now use the renderscript to get the blurred bitmap shown here http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android/ and draw it to your view.

Rohit
  • 1,001
  • 1
  • 11
  • 20
  • I see that this is using renderscript and that will use the gpu, but is this fast, since it has to do with all the time? – CQM Apr 28 '14 at 21:38
  • Note that you can only blur content you can access from your own activity. – Oded Breiner Jan 09 '15 at 15:17
  • The RenderScript in the link works perfect, however you should note that it's written in C# since that's a Xamarin blog. Fortunately, it's childs work to convert it to Java. – halileohalilei Aug 16 '16 at 13:07
0

Yes it is possible. Instead of creating a Dialog, Create and Activity and In your Manifest add android:theme="@android:style/Theme.Dialog" to your activity like below:

<activity 
    android:name=".Activity" 
    android:label="@string/title_activity" 
    android:theme="@android:style/Theme.Dialog">
  <intent-filter>
  <action android:name="example.package" /> 
  <category android:name="android.intent.category.DEFAULT" /> 
  </intent-filter>
</activity>
Caleb Bramwell
  • 1,332
  • 2
  • 12
  • 24
0

It can be done, but there's no quick and easy way to do it. Check our the BlurMask filter in the Android developer documentation or Android, how to blur/glass/frost current activity for some suggested steps.

Community
  • 1
  • 1
Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
0

Create the blurred bitmap in Photoshop and set it as the Activity/Dialog's background drawable.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • 1
    I don't think this is what the asker is looking for, that would look the same 100% of the time. I am guessing he wants something more dynamic that has the effect of dialog made of frosted glass. – satur9nine Aug 30 '13 at 07:13
  • @satur9nine The OP never mentioned anything about it needing to be dynamic. But if this is what he meant, then yes, the blurred effect may need to be generated at runtime. – Alex Lockwood Aug 30 '13 at 15:24