aboutsummaryrefslogtreecommitdiffstats
path: root/layoutopt/libs/uix/src/resources/rules/UselessLayout.rule
diff options
context:
space:
mode:
Diffstat (limited to 'layoutopt/libs/uix/src/resources/rules/UselessLayout.rule')
-rw-r--r--layoutopt/libs/uix/src/resources/rules/UselessLayout.rule8
1 files changed, 5 insertions, 3 deletions
diff --git a/layoutopt/libs/uix/src/resources/rules/UselessLayout.rule b/layoutopt/libs/uix/src/resources/rules/UselessLayout.rule
index d9bd6f0..70381b0 100644
--- a/layoutopt/libs/uix/src/resources/rules/UselessLayout.rule
+++ b/layoutopt/libs/uix/src/resources/rules/UselessLayout.rule
@@ -5,13 +5,15 @@
// Conditions:
// - The node has children
// - The node does not have siblings
+// - The node's parent is not a scroll view (horizontal or vertical)
// - The node does not have a background or its parent does not have a
// background or neither the node and its parent have a background
// - The parent is not a <merge/>
-if (!xml.isRoot() && xml['..'].name() != "merge" && xml['..']['*'].size() == 1 &&
- xml['*'].size() > 0 && ((xml.'@android:background' || xml['..'].'@android:background') ||
- (!xml.'@android:background' && !xml['..'].'@android:background'))) {
+if (!xml.isRoot() && !(xml['..'].name() in ["ScrollView", "HorizontalScrollView"]) &&
+ xml['..']['*'].size() == 1 && xml['*'].size() > 0 && ((xml.'@android:background' ||
+ xml['..'].'@android:background') || (!xml.'@android:background' &&
+ !xml['..'].'@android:background'))) {
analysis << [node: node, description: "This ${xml.name()} layout or " +
"its ${xml['..'].name()} parent is " +
"${xml['..'].'@android:id' ? "possibly useless" : "useless"}"]