New layout optimization tool. Run layoutopt on the command line.

Change-Id: I8e4697e19ca8a203dc8a41b464f7cb46d52184b0
This commit is contained in:
Romain Guy
2009-10-05 02:21:30 -07:00
parent d13d440d43
commit 3958d08fd4
27 changed files with 1857 additions and 0 deletions

View File

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