aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--layoutopt/libs/uix/src/resources/rules/InefficientWeight.rule2
-rw-r--r--layoutopt/samples/inefficient_weight.xml15
2 files changed, 16 insertions, 1 deletions
diff --git a/layoutopt/libs/uix/src/resources/rules/InefficientWeight.rule b/layoutopt/libs/uix/src/resources/rules/InefficientWeight.rule
index 0de9350..928d7a1 100644
--- a/layoutopt/libs/uix/src/resources/rules/InefficientWeight.rule
+++ b/layoutopt/libs/uix/src/resources/rules/InefficientWeight.rule
@@ -12,7 +12,7 @@ if (parent.is("LinearLayout") && node.'@android:layout_weight' &&
parent.'*'.findAll{ it.'@android:layout_weight' }.size() == 1) {
def dimension = parent.'@android:orientation' == "vertical" ?
"android:layout_height" : "android:layout_width"
- if (node."@${dimension}"[0] != 0) {
+ if (node."@${dimension}"[0] != '0') {
analysis << "Use an ${dimension} of 0dip instead of ${node."@${dimension}"} " +
"for better performance"
}
diff --git a/layoutopt/samples/inefficient_weight.xml b/layoutopt/samples/inefficient_weight.xml
index c687ed8..785350a 100644
--- a/layoutopt/samples/inefficient_weight.xml
+++ b/layoutopt/samples/inefficient_weight.xml
@@ -25,5 +25,20 @@
android:layout_weight="1.0" />
</LinearLayout>
+
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+
+ android:orientation="vertical">
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1.0" />
+
+ </LinearLayout>
</LinearLayout> \ No newline at end of file