Recent Changes‎ > ‎

New Lint Rules

posted Nov 24, 2011, 9:37 AM by Tor Norbye   [ updated Nov 24, 2011, 11:04 AM ]
We now have several new lint rules since the initial set from last week:

Typography suggestions: Looks at your string files and suggests replacing hyphens in numeric ranges with en dash characters, double hyphens with an em dash character, triple dots with an ellipsis character, (c) with a copyright symbol, and so on. There is also a rule checking for quotes usage, suggesting replacing straight quotes with directional quotes (both for single quotes and double quotes), and it also warns about using the grave accent character as a quoting character, like `this'. This last check is disabled by default because whether directional quotes is preferred isn't settled yet, but you can enable this check with --enable TypographyQuotes (or using the Eclipse options UI.)  These warnings also have Eclipse quick-fixes to automatically make the suggested edits:
Wrong layout parameters: Makes sure that layout parameters found on views matches the parent layout. When moving view code around it's pretty easy to end up with obsolete layout parameters, such as a layout_weight attribute in a RelativeLayout. This lint rule not only checks within layouts, but also checks across <include> and <merge> tags to make sure that when you for example include a layout, the layout parameters on the root element of the included layout are correct. (This lint warning also has an Eclipse quick-fix to correct it.)

Overdraw Detector: Looks for "overdraw", where you have a layout which specifies a background drawable to be painted all over the background, where the same layout is using a theme which also paints a background. This means that the theme background will be painted and then completely covered by the view background. It's more efficient in this case to use a custom theme with a null theme background (or if your background is translucent, it's more efficient to premix a single image and use that instead.)

Layout performance: Finds LinearLayouts with weights where you should set android:baselineAligned="false" for better performance, and also finds cases where you have nested weights which can cause performance problems.

Deprecation: Warns about usages of deprecated APIs (currently just AbsoluteLayout, more planned).

(You can download a preview of lint as part of the ADT 16 Preview. See the Download page for details.)