• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Rule: MergeRootFrameLayout
2//
3// Description: Checks whether the root node of the XML document can be
4//              replaced with a <merge /> tag.
5//
6// Conditions:
7// - The node is the root of the document
8// - The node is a FrameLayout
9// - The node is match_parent in both orientation *or* it has no layout_gravity
10// - The node does not have a background nor a foreground
11// - The node does not have padding
12
13if (node.isRoot() && node.is("FrameLayout") && !node.'@android:background' &&
14        !node.'@android:foreground' && ((node.isWidthFillParent() &&
15                node.isHeightFillParent()) || !node.'@android:layout_gravity') &&
16        !node.hasPadding()) {
17    analysis << "The root-level <FrameLayout/> can be replaced with <merge/>"
18}
19