diff options
author | Tor Norbye <tnorbye@google.com> | 2013-01-03 10:03:51 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-01-03 10:16:16 -0800 |
commit | c8e6f23015e405edc179327a221a264b4df4b670 (patch) | |
tree | b192baf6201951601854477c5d9a1ca08686f4b8 /lint/cli | |
parent | e3ea7ff03b5fdcde660054322feb82b3c000f8e1 (diff) | |
download | sdk-c8e6f23015e405edc179327a221a264b4df4b670.zip sdk-c8e6f23015e405edc179327a221a264b4df4b670.tar.gz sdk-c8e6f23015e405edc179327a221a264b4df4b670.tar.bz2 |
27869: Lint rule for LinearLayout which doesn't specify orientation
This adds a check for cases where you have a LinearLayout which
does not specify an orientation (meaning it's horizontal), yet
it contains multiple children, and one of the children prior to
the last one sets its width to fill_parent or match_parent (without
a weight).
This is a common pitfall for new developers who create the layout
and assume it's vertical, and at runtime only see the first child,
not realizing the remainder are off screen to the right.
Change-Id: Ief9604d8a8fc84849d1a8f2df6d7ec0b75b13eaa
Diffstat (limited to 'lint/cli')
-rw-r--r-- | lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java index 644bb10..c642ab1 100644 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java +++ b/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java @@ -27,14 +27,16 @@ public class InefficientWeightDetectorTest extends AbstractCheckTest { public void testWeights() throws Exception { assertEquals( + "res/layout/inefficient_weight.xml:3: Error: Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width=\"match_parent\" [Orientation]\n" + + "<LinearLayout\n" + + "^\n" + "res/layout/inefficient_weight.xml:10: Warning: Use a layout_width of 0dip instead of match_parent for better performance [InefficientWeight]\n" + " android:layout_width=\"match_parent\"\n" + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + "res/layout/inefficient_weight.xml:24: Warning: Use a layout_height of 0dip instead of wrap_content for better performance [InefficientWeight]\n" + " android:layout_height=\"wrap_content\"\n" + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", + "1 errors, 2 warnings\n", lintFiles("res/layout/inefficient_weight.xml")); } @@ -122,6 +124,4 @@ public class InefficientWeightDetectorTest extends AbstractCheckTest { lintFiles("res/layout/wrong0dp.xml")); } - - } |