What is an Android DecorView?

AndroidWindowAndroid View

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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.

Solution 2 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnmrView Question on Stackoverflow
Solution 1 - AndroidnKnView Answer on Stackoverflow
Solution 2 - Androidthe_proleView Answer on Stackoverflow