New layout optimization tool. Run layoutopt on the command line.
Change-Id: I8e4697e19ca8a203dc8a41b464f7cb46d52184b0
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// 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/>"]
|
||||
}
|
||||
Reference in New Issue
Block a user