Reputation: 19446
I would like to make a quick intro to my app for new users. The intro would highlight features in the ui and explain the functions, similar to the Slices(see screen shot below) and Youtube app.
I imagine this involves a transparent overlay of the entire screen and then getting the location of the view on the screen so it can be circled or highlighted in the overlay. I am not sure how to go about making one section of the overlay not transparent. Any ideas?
Upvotes: 5
Views: 1521
Reputation: 7329
To get the effect you want in the simplest way possible you would want to create new assets and have them overlay your opaque background. This creates the illusion of the effect with out the pain of getting the dynamic way to work correctly on all devices.
The dynamic way to punch holes in a layer involves creating a custom view, overriding the dispatchDraw method and applying a custom mask to the canvas. For punching holes in the canvas, your custom paint object would be created like this:
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
Compatibility isn't great with this so I'd recommend faking it.
Upvotes: 2
Reputation: 3727
Just add a new View() and set the background to black with 70% alpha. Make sure the Parent ViewGroup of your Fragment is a Relativelayout and the call bringChildToFront(MyHighlightedView).
overlay=new View();
overlay.setBackgroundColor(#*BLACKWITHALPHAVALUE*);
getView().addView(overlay, new LayoutParams(MATCH_PARENT,MATCH_PARENT);
getView().bringChildToFront(overlay);
getView().bringChildToFront(MyHighlightedView);
Upvotes: 1