2

I want to see if my application conforms with the Material Design guidelines regarding metrics and adjust where required. For that I'd wish to have a 8dp square grid or 4dp baseline grid drawn over my whole window without intercepting touch events, so that I could tap and scroll as usual (think of "Show layout bounds" mode in dev options). It should look something like this:

baseline overlay

Questions:

  1. How do I put such view on the top of everything and make it "click-through"?
  2. Or maybe there are already tools / libraries / snippets for achieving this? UPD This one is answered, thank you! Question 1 remains open for curiosity reasons
Actine
  • 2,867
  • 2
  • 25
  • 38

2 Answers2

2

This is what I use

Note: I have no affiliation to the author of the app, it's just what I use extensively in my own development.

Elli White
  • 1,440
  • 1
  • 12
  • 21
2

UPD2: The app referenced by @john actually has their sources open. Looks like this snippet does it. So simple.

final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.TRANSLUCENT
);

final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

wm.addView(myOverlayView, lp);
Actine
  • 2,867
  • 2
  • 25
  • 38