diff options
author | Tor Norbye <tnorbye@google.com> | 2013-01-13 19:57:24 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-01-14 16:47:11 -0800 |
commit | dad4e39fce46a93429a3f9afc51d590174e1e4d8 (patch) | |
tree | f5fc78fa2e4f1226b151d1d38e9ed3cd2ce29e56 | |
parent | 6e2caffa39a335902247ce04925887f676849fb1 (diff) | |
download | sdk-dad4e39fce46a93429a3f9afc51d590174e1e4d8.zip sdk-dad4e39fce46a93429a3f9afc51d590174e1e4d8.tar.gz sdk-dad4e39fce46a93429a3f9afc51d590174e1e4d8.tar.bz2 |
27869: Don't require a LinearLayout orientation when style is set
Change-Id: I783e001fe84d825e116c6b2a882bcf2d22c61884
2 files changed, 18 insertions, 1 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml index 058fde1..196e00b 100644 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml +++ b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml @@ -41,4 +41,20 @@ </LinearLayout> + <LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + style="@style/MyStyle" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <Button + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + </LinearLayout> + + </LinearLayout>
\ No newline at end of file diff --git a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/InefficientWeightDetector.java b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/InefficientWeightDetector.java index fefe461..0608de1 100644 --- a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/InefficientWeightDetector.java +++ b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/InefficientWeightDetector.java @@ -22,6 +22,7 @@ import static com.android.SdkConstants.ATTR_LAYOUT_HEIGHT; import static com.android.SdkConstants.ATTR_LAYOUT_WEIGHT; import static com.android.SdkConstants.ATTR_LAYOUT_WIDTH; import static com.android.SdkConstants.ATTR_ORIENTATION; +import static com.android.SdkConstants.ATTR_STYLE; import static com.android.SdkConstants.LINEAR_LAYOUT; import static com.android.SdkConstants.RADIO_GROUP; import static com.android.SdkConstants.VALUE_FILL_PARENT; @@ -215,7 +216,7 @@ public class InefficientWeightDetector extends LayoutDetector { } } } - if (maxWidthSet) { + if (maxWidthSet && !element.hasAttribute(ATTR_STYLE)) { String message = "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\""; |