76

http://developer.android.com/reference/android/view/Window.html#getDecorView():

Retrieve the top-level window decor view (containing the standard window frame/decorations and the client's content inside of that), which can be added as a window to the window manager.

This is baffling. It is not clear what the standard "window frame/decorations" are. I'm at a loss as to what this is, exactly, and the documentation is terrible. Does it exist inside the application's window? Does it surround the application's window?

I have never seen an Android window with noticeable window decorations. And "which can be added as a window" implies that a decor view is a window, but that contradicts the class hierarchy (View is not a subclass of Window).

So what's the deal? What exactly is the decor view?

nmr
  • 16,625
  • 10
  • 53
  • 67

2 Answers2

62

Seems that one of the places where it's best defined is in Romain Guy's Blog:

The DecorView is the view that actually holds the window’s background drawable. Calling getWindow().setBackgroundDrawable() from your Activity changes the background of the window by changing the DecorView‘s background drawable. As mentioned before, this setup is very specific to the current implementation of Android and can change in a future version or even on another device.

Pacerier
  • 86,231
  • 106
  • 366
  • 634
nKn
  • 13,691
  • 9
  • 45
  • 62
  • 6
    My redux is: the decor view is the true root of the `Window`'s view hierarchy. It contains both the "decor" (i.e. the window's title (action bar?), or a dialog's "frame" (~= the view which draws the actual pixels of the dialog frame, as seen in pre-Holo) and also contains the app-supplied content view. AFAIK it exists entirely within the bounds of the window, and does not surround it, and is not itself a window in any sense. – nmr Apr 24 '14 at 19:17
  • And I believe it's the one responsible for scheduling layout & measure traversals. – stdout Nov 17 '16 at 09:48
  • @zgulser Is there documentation pointing to DecorView scheduling layouts and measures? – IgorGanapolsky Nov 23 '18 at 12:37
  • 1
    You may try https://mathias-garbe.de/files/introduction-android-graphics.pdf page 31. – stdout Nov 23 '18 at 13:39
2

Decor view appears to contain screen resolution? I get 1920.

var verticalScreenRes = act.window.decorView.height.toFloat() // 1920

then verify

adb -s emulator-5554 shell wm size
Physical size: 1080x1920
the_prole
  • 8,275
  • 16
  • 78
  • 163