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

16 lines
632 B
Plaintext

// Rule: UseCompoundDrawables
//
// Description: Checks whether the current node can be replaced by a TextView
// using compound drawables.
//
// Conditions:
// - The node is a LinearLayout
// - The node has two children, ImageView and TextView
// - The ImageView does not have a weight
if (xml.is("LinearLayout") && xml['*'].size() == 2 && xml.'TextView'.size() == 1 &&
xml.'ImageView'.size() == 1 && !xml.'ImageView'.'@android:layout_weight') {
analysis << [node: node, description: "This tag and its children can be replaced by one " +
"<TextView/> and a compound drawable for the image"]
}