blob: f92c2b1caf12767eb19d5271fc224bc94e86927f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Rule: MergeRootFrameLayout
//
// Description: Checks whether the root node of the XML document can be
// replaced with a <merge /> tag.
//
// Conditions:
// - The node is the root of the document
// - The node is a FrameLayout
// - The node is fill_parent in both orientation *or* it has no layout_gravity
// - The node does not have a background nor a foreground
if (xml.isRoot() && xml.is("FrameLayout") && !xml.'@android:background' &&
!xml.'@android:foreground' && ((node.isWidthFillParent() &&
node.isHeightFillParent()) || !xml.'@android:layout_gravity')) {
analysis << [node: node, description: "The root-level <FrameLayout/> can be " +
"replaced with <merge/>"]
}
|