8

I know we can dim/blur the screen, as shown on this post.

What should I do in order to dim/blur only a part of it, leaving a single (or multiple) view without any effect, so that the entire screen will have an effect of a highlighted view?

Also, will it work even if I make a dialog on top of the current screen, so that the dialog and the highlighted view will remain without any effect?

Community
  • 1
  • 1
android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • it seems to me like adding an overlay `View` with dark background and low alpha should do the trick – thepoosh Dec 25 '12 at 11:26
  • but what about the part/s that i don't want to dim/blur ? i want to protect a part of the screen from being dimmed/blurred . – android developer Dec 25 '12 at 11:54
  • The "protected" part will be covered by a completely transparent (alpha = ff) area of the overlaid View. – Phantômaxx Jun 07 '14 at 16:50
  • @DerGolem Can you please explain how? – android developer Jun 07 '14 at 20:05
  • @androiddeveloper OK, let's use the overlaid View. It's background uses alpha to give an effect of semi-transparency (say it's #80000000) and full transparency (#00000000) so you prepare a PNG that you will use as a 9 patch (so it will be very small in both size and byte count) which has two areas and this should make a very cheap trick. – Phantômaxx Jun 08 '14 at 09:08
  • @DerGolem This question was a long time ago that I don't even remember why I needed it for. You solution seems legit, but as opposed to the question which is about any number of views, you handled a single one, plus it's not the blur effect... I'm also not sure if your solution will work on a dialog and a view together. – android developer Jun 08 '14 at 09:29
  • @androiddeveloper Oh, well I just threw in my two cents. Since also the poosh proposed a similar solution. For the blur... well I think it's a matter of having a very small image and set it as a background. By scaling, it will be stretched, so the blur effect will be achieved automatically. – Phantômaxx Jun 08 '14 at 09:33
  • @DerGolem Never thought about this way to make a blurry image, but I think it's a bit different than the normal way. you could also use RenderScript for this task. – android developer Jun 08 '14 at 09:49
  • @androiddeveloper You could... but why paying for something you can get for free? ;) In terms of effort, of course. I guess that a Matrix could also make the work. But! If I can have it at no cost (0 lines of code)... I choose no cost. Of course, I didn't verify if it's doable, nor the quality you get. But conceptually, it could work, since Android automatically stretches the background images. – Phantômaxx Jun 08 '14 at 09:51
  • 1
    @DerGolem true true... – android developer Jun 08 '14 at 10:05
  • Now, stimulated by curiosity, I'm doing a proof-of-a-concept I reduced an image to 640*640 @ 640 dpi (xxxdpi) and made all versions down to 120*120 @ 120 dpi (ldpi) - I'll give an ImageView the double in both layout_width and height (that is, since we reason in mdpi, 320*320). So, I'm expecting to see the image nicely blurred at all resolutions (will do a couple of tests ldpi, hdpi - maybe mdpi too). – Phantômaxx Jun 08 '14 at 10:17
  • Well, I tried both the half and the quarter scale... none of which worked very well. I guess a Matrix or a RenderScript will do much a better work. – Phantômaxx Jun 08 '14 at 10:34
  • @androiddeveloper OK, my idea was **bad**. But I did some research and this page seems... fantastic! http://nicolaspomepuy.fr/blur-effect-for-android-design/ - Just wanted to share it – Phantômaxx Jun 08 '14 at 10:52
  • @androiddeveloper ... even **cooler**! Look at what I found, while further investigating: http://trickyandroid.com/advanced-blurring-techniques/ It combines my idea with yours (Scaling Down + RenderScript or **FastBlur** + Scaling up) - Not only it's **LIGHTSPEED-FAST**, but it's also compatible with older OS versions. Enjoy! – Phantômaxx Jun 10 '14 at 10:02
  • 1
    @DerGolem nice. note that Renderscript has a library that can handle old OS versions too. It does it using JNI. – android developer Jun 10 '14 at 11:07
  • @androiddeveloper Yet this FastBlur seems to be a real rocket, when compared... ;) – Phantômaxx Jun 10 '14 at 11:10
  • @DerGolem ok thank you. BTW, if you like to play with bitmaps in JNI, you can check out my library here: https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations – android developer Jun 10 '14 at 12:06
  • @androiddeveloper Thank you. I don't even know what JNI is... for my tendency, I try to avoid importing libraries (well svg and graph plotting *NEED* a 3rd party library, and so using the support library) - I try to do everything with what I already have, if possible. If forced, and with some reluctance, I add some more libraries... :) – Phantômaxx Jun 10 '14 at 12:13
  • @DerGolem JNI is something that allows you to write in C/C++ for Java based apps. Android has both Java and C/C++ code within its framework, and you can also make your own apps with a lot of C/C++ code. Using C/C++, you are not limited to the memory restrictions you have on Java (the heap, for example) and you have a lot of power and speed, but you have a lot of responsibility too (freeing memory by yourself, for example). This is usually used on games ,heavy-consuming apps, and real-time apps. – android developer Jun 10 '14 at 12:33
  • @androiddeveloper I see. I see why I don't know anything of it. As a seasoned VB NET (and VB before and QB and other 1000 variants of Basic), I always refused to have anything to do with memory management. Does JNI work in tandem with NDK? Or is it something apart and can be used "stand alone"? – Phantômaxx Jun 10 '14 at 12:36
  • @DerGolem NDK is just the SDK of Android to use JNI . JNI is like the bridge between Java-world and C/C++ world, while NDK is like whoever made the bridge – android developer Jun 10 '14 at 12:38
  • So, to use JNI, I have to choose Android NDK, instead of Android SDK, in the project porperties, right? – Phantômaxx Jun 10 '14 at 12:41
  • @DerGolem You need both, as all Android apps use Java as the initial place to start from (onCreate, etc...) . You can download the library and sample I made to see how things work. – android developer Jun 10 '14 at 12:44
  • try jhlab jar file and read out the tutorial this may be really helpfull to you here is the link of that http://www.jhlabs.com/ – Hasnain Aug 23 '14 at 13:15
  • @Hasnain Even though the library looks nice, it seem to use Java2d , which is something that Android doesn't have. Maybe you can import it to Android? – android developer Aug 23 '14 at 17:41

1 Answers1

1

I think Showcase View Might be helpful for you.
The ShowcaseView library is designed to highlight and showcase specific parts of apps to the user with a distinctive and attractive overlay. This library is great for pointing out points of interest for users, gestures, or obscure but useful items.

The library is based on the "Cling" view found in the Launcher on Ice-Cream Sandwich and Jelly Bean, but extended to be easier to use.

LINK TO GitHub

Hoh
  • 1,196
  • 1
  • 12
  • 30
  • 1
    I've actually tried to find an alternative to this library, since I've found there too many bugs: http://stackoverflow.com/questions/17972903/alternative-to-showcase-library-for-app-user-tutorials . maybe they've changed since last time I've tried them. – android developer Aug 23 '14 at 17:42