Files
android_development/tools/layoutopt/libs/uix/src/resources/rules/MergeRootFrameLayout.rule
Romain Guy 5a31898020 Add new rules to layoutopt: UseCompoundDrawables and UselessLayout.
Change-Id: I5dfb2567d923da8442b1df1e703e4ebca6e9523b
2009-10-05 11:59:21 -07:00

18 lines
729 B
Plaintext

// 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/>"]
}