4

In Android Studio, Tools -> Layout Inspector, what does a greyed out(subdued, dim) view in the View Tree mean? The layer still has VISIBLE properties

I don't see any explanation in the docs, https://developer.android.com/studio/debug/layout-inspector and there isn't a tooltip when hovering the view.

You can download the .li layout capture in question here


For context/reference, I am trying to figure out why the fragment isn't showing up in the id/content_container, https://gitlab.com/gitlab-org/gitter/gitter-android-app/issues/108

The project is open source if you want to check out the code yourself, https://gitlab.com/gitlab-org/gitter/gitter-android-app

MLM
  • 3,660
  • 3
  • 41
  • 66

2 Answers2

6

The grayed-out Views are not rendered at the time when the LayoutInspector snapshot is taken because they don't need to be shown.

Examples:

  • the NavigationView in your code is currently hidden (you can test if I'm right by opening it and taking another snapshot with LayoutInspector)
  • the RecyclerView in the NavigationView is grayed-out as long as it has no Adapter assigned to it (and maybe also if it is empty - did not test it)
  • sometimes Views don't fit on the screen, like when you forget to make a LinearLayout "vertical" and so most of its children are to the right of the right screen edge
Bö macht Blau
  • 12,820
  • 5
  • 40
  • 61
2

these nodes are boilerplate layout, which are essential for the framework.

that ContentFrameLayout is the root-view with id android.R.id.content,

which has R.layout.activity_main inflated and it adds further nested nodes into there.

basicallyy it's name-space android.R (in gray) vs. im.gitter.gitter.R (in black).

nodes from android.R might still turn black, when they have a visble layout inflated.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • What about this case where there are child elements? https://i.imgur.com/aIfIESr.png I do see `INVISIBLE` on `NavigationView` though? Perhaps it ties in with nothing drawing/rendering? – MLM Dec 12 '18 at 18:54
  • @MLM that child element there might also be boilerplate, without a custom view inflated; they need to be there, because else the framework would throw NPE. I've also checked https://gitlab.com/gitlab-org/gitter/gitter-android-app/tree/master/app/src/main/res/layout ...just not sure which one it is. – Martin Zeitler Dec 12 '18 at 18:56
  • For reference, it's in the [`app/src/main/res/layout/activity_main.xml`](https://gitlab.com/gitlab-org/gitter/gitter-android-app/blob/0ff8428f6e2fc310bdb5dd7a7d61a2a7b2dd53ac/app/src/main/res/layout/activity_main.xml) and associated [`app/src/main/java/im/gitter/gitter/activities/MainActivity.java`](https://gitlab.com/gitlab-org/gitter/gitter-android-app/blob/0ff8428f6e2fc310bdb5dd7a7d61a2a7b2dd53ac/app/src/main/java/im/gitter/gitter/activities/MainActivity.java) – MLM Dec 12 '18 at 19:01
  • What is considered layout boilerplate? Why aren't other `FrameLayout`, `ContentFrameLayout`, `LinearLayout` in grey? – MLM Dec 12 '18 at 19:04
  • 1
    @MLM that `ContentFrameLayout`is the root-view with id `android.R.id.content`, which has `R.layout.activity_main` inflated and it adds further nested nodes into there. which originate from the custom xml. when looking at `MainActivity.java`, there is no `NavigationView` header being inflated; if you'd add a custom header into there, it shouldn't be grayed out anymore (just to proof what I'm telling). updated the answer, too... and that name-space thing, seems to be the best explanation - because it is the difference in between framework vs. app resources. – Martin Zeitler Dec 12 '18 at 19:42