From 0980e41e97db0c7e57d114a1aae76663d637ba87 Mon Sep 17 00:00:00 2001 From: Rich Hyndman Date: Wed, 15 Feb 2012 16:46:51 +0100 Subject: docs: Added Lint into Android Training and removed Layoutopt. Change-Id: Ib818ba3ab12fff79dbede69ebf543a8e4be6f3df --- docs/html/images/training/lint_icon.png | Bin 0 -> 22128 bytes .../improving-layouts/optimizing-layout.jd | 45 +++++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 docs/html/images/training/lint_icon.png (limited to 'docs/html') diff --git a/docs/html/images/training/lint_icon.png b/docs/html/images/training/lint_icon.png new file mode 100644 index 0000000..118a741 Binary files /dev/null and b/docs/html/images/training/lint_icon.png differ diff --git a/docs/html/training/improving-layouts/optimizing-layout.jd b/docs/html/training/improving-layouts/optimizing-layout.jd index 65c8af7..0eaf199 100644 --- a/docs/html/training/improving-layouts/optimizing-layout.jd +++ b/docs/html/training/improving-layouts/optimizing-layout.jd @@ -18,7 +18,7 @@ next.link=reusing-layouts.html
  1. Inspect Your Layout
  2. Revise Your Layout
  3. -
  4. Use Layoutopt
  5. +
  6. Use Lint
@@ -44,7 +44,7 @@ is inflated repeatedly, such as when used in a {@link android.widget.ListView} o android.widget.GridView}.

In this lesson you'll learn to use Heirachy Viewer and Hierarchy Viewer and Layoutopt to examine and optimize your layout.

@@ -53,7 +53,7 @@ layout.

Inspect Your Layout

The Android SDK tools include a tool called Heirachy Viewer that allows +href="{@docRoot}guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer that allows you to analyze your layout while your application is running. Using this tool helps you discover bottlenecks in the layout performance.

@@ -130,27 +130,28 @@ example of how each layout has appropriate uses and you should carefully conside layout weight is necessary.

-

Use Layoutopt

+

Use Lint

+ +

It is always good practice to run the Lint tool on your layout files to search for possible view hierarchy optimizations. Lint has replaced the Layoutopt tool and has much greater functionality. Some examples of Lint rules are:

+ + + +

Another benefit of Lint is that it is integrated into the Android Development Tools for Eclipse (ADT 16+). Lint automatically runs whenever you export an APK, edit and save an XML file or use the Layout Editor. To manually force Lint to run press the Lint button in the Eclipse toolbar.

+ + + +

When used inside Eclipse, Lint has the ability to automatically fix some issues, provide suggestions for others and jump directly to the offending code for review. If you don’t use Eclipse for your development, Lint can also be run from the command line. More information about Lint is available at tools.android.com.

+ + -

It is always good practice to also run the layoutopt tool on your final layout files -to search for places in your view hierarchy that may be optimized. Layoutopt is also in your SDK -{@code tools/} directory and takes a layout directory name or a space-separated list of layout files -that you'd like to inspect.

-

When you run {@code layoutopt} on a layout file, it prints a line number for each issue found, a -description of the issue, and for some types of issues it also suggests a resolution. For -example:

-
-$ layoutopt samples/
-samples/compound.xml
-   7:23 The root-level <FrameLayout/> can be replaced with <merge/>
-   11:21 This LinearLayout layout or its FrameLayout parent is useless
-samples/simple.xml
-   7:7 The root-level <FrameLayout/> can be replaced with <merge/>
-
-

After you apply the suggested layout optimizations, run Hierarchy Viewer again to inspect the -performance changes.

-- cgit v1.1