1page.title=Android Developer Tools 2page.tags=adt 3@jd:body 4 5 <div id="qv-wrapper"> 6 <div id="qv"> 7 <h2>In this document</h2> 8 9 <ol> 10 <li><a href="#tools">SDK Tools Integration</a></li> 11 12 <li><a href="#editors">Code Editors</a> 13 <ol> 14 <li><a href="#resource-linking">Resource linking enhancements</a></li> 15 </ol> 16 </li> 17 18 <li><a href="#graphical-editor">Graphical Layout Editor</a> 19 <ol> 20 <li><a href="#canvas">Canvas and outline view</a></li> 21 <li><a href="#palette">Palette</a></li> 22 <li><a href="#config-chooser">Configuration chooser</a></li> 23 </ol> 24 </li> 25 26 <li><a href="#refactoring">Layout Factoring Support</a></li> 27 <li><a href="#Updating">Updating the ADT Plugin</a></li> 28 29 </ol> 30 </div> 31 </div> 32 33 <p>ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of 34 tools that are integrated with the Eclipse IDE. It offers you access to many features that help 35 you develop Android applications. ADT 36 provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid 37 prototyping, designing, and building of your application's user interface.</p> 38 39<p class="note"><strong>Note:</strong> 40If you have been using Eclipse with ADT, be aware that <a 41href="{@docRoot}tools/studio/index.html">Android Studio</a> is now the official IDE 42for Android, so you should migrate to Android Studio to receive all the 43latest IDE updates. For help moving projects, 44see <a href="/sdk/installing/migrate.html">Migrating to Android 45Studio</a>.</p> 46 47<p>If you still wish to use the ADT plugin for Eclipse, see 48<a href="{@docRoot}sdk/installing/installing-adt.html">Installing Eclipse Plugin.</a> 49</p> 50 51 52 <h2 id="tools">SDK Tools Integration</h2> 53 54 <div class="sidebox-wrapper"> 55 <div class="sidebox"> 56 <h2>Need help designing icons?</h2> 57 <p>The <a href="http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html">Android 58 Asset Studio</a> is a web-based tool that lets you generate icons from existing images, 59 clipart, or text. It also generates the icons with different DPIs for different screen sizes and 60 types.</p> 61 62 </div> 63 </div> 64 65 <p>Many of the tools that you can start or run from the command line are integrated into ADT. 66 They include:</p> 67 68 <ul> 69 <li><a href="{@docRoot}tools/debugging/debugging-tracing.html">Traceview</a>: 70 Allows you to profile your program's execution 71 (<strong>Window > Open Perspective > Traceview</strong>). </li> 72 73 <li><a href="{@docRoot}tools/help/android.html">android</a>: Provides access to 74 the Android SDK Manager and AVD Manager. Other <code>android</code> features such as creating or 75 updating projects (application and library) are integrated throughout the Eclipse IDE. </li> 76 77 <li><a href="{@docRoot}tools/debugging/debugging-ui.html#HierarchyViewer">Hierarchy 78 Viewer</a>: Allows you to visualize your application's view hierarchy to find inefficiencies 79 (<strong>Window > Open Perspective > Hierarchy Viewer</strong>).</li> 80 81 <li><a href="{@docRoot}tools/debugging/debugging-ui.html#pixelperfect">Pixel 82 Perfect</a>: Allows you to closely examine your UI to help with designing and building. 83 (<strong>Window > Open Perspective > Pixel Perfect</strong>).</li> 84 85 <li><a href="{@docRoot}tools/debugging/ddms.html">DDMS</a>: Provides 86 debugging features including: screen capturing, thread and heap information, and logcat 87 (<strong>Window > Open Perspective > DDMS</strong>).</li> 88 89 <li><a href="{@docRoot}tools/help/adb.html">adb</a>: Provides access to 90 a device from your development system. Some features of 91 <code>adb</code> are integrated into ADT such as project installation (Eclipse run menu), 92 file transfer, device enumeration, and logcat (DDMS). You must access the more advanced 93 features of <code>adb</code>, such as shell commands, from the command line.</li> 94 95 <li><a href="{@docRoot}tools/help/proguard.html">ProGuard</a>: Allows code obfuscation, 96 shrinking, and optimization. ADT integrates ProGuard as part of the build, if you <a href= 97 "{@docRoot}tools/help/proguard.html#enabling">enable it</a>.</li> 98 </ul> 99 100<h2 id="editors">Code Editors</h2> 101 102 <p>In addition to Eclipse's standard editor features, ADT provides custom XML editors to help 103 you create and edit Android manifests, resources, menus, and layouts in a form-based or graphical 104 mode. Double-clicking on an XML file in Eclipse's package explorer opens the 105 appropriate XML editor. 106 107 <div class="sidebox-wrapper"> 108 <div class="sidebox"> 109 <h2>Google I/O Session Video</h2> 110 <p>View the segment on the <a href= 111 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=30m50s">XML editors</a> for more 112 information.</p> 113 </div> 114 </div> 115 116 <p class="note"><strong>Note:</strong> You can edit Android-specific XML files (such as a layout 117or manifest) in both a graphical mode and also an XML markup mode. You can switch between 118these modes with the pair of tabs at the bottom of each custom XML editor.</p> 119 120 <p>In addition, some special file types that don't have custom editors, such as drawables, animations, 121 and color files offer editing enhancements such as XML tag completion.</p> 122 123<p>ADT provides the following custom, form-based XML editors:</p> 124 125 <dl> 126 127 <dt><strong>Graphical Layout Editor</strong></dt> 128 129 <dd>Edit and design your XML layout files with a drag and drop interface. The layout editor 130 renders your interface as well, offering you a preview as you design your layouts. This editor 131 is invoked when you open an XML file with a view declared (usually declared in 132 <code>res/layout</code>. For more information, see <a href="#graphical-editor">Graphical Layout 133 Editor</a>.</dd> 134 135 <dt><strong>Android Manifest Editor</strong></dt> 136 137 <dd>Edit Android manifests with a simple graphical interface. This editor is invoked 138 when you open an <code>AndroidManifest.xml</code> file.</dd> 139 140 <dt><strong>Menu Editor</strong></dt> 141 142 <dd>Edit menu groups and items with a simple graphical interface. This editor is 143 invoked when you open an XML file with a <code><menu></code> declared (usually located in 144 the <code>res/menu</code> folder).</dd> 145 146 <dt><strong>Resources Editor</strong></dt> 147 148 <dd>Edit resources with a simple graphical interface. This editor is invoked when 149 you open an XML file with a <code><resources></code> tag declared.</dd> 150 151 <dt><strong>XML Resources Editor</strong></dt> 152 153 <dd>Edit XML resources with a simple graphical interface. This editor is invoked 154 when you open an XML file.</dd> 155 </dl> 156 157 158 <h3 id="resource-linking">Resource linking enhancements</h3> 159 <p>In addition to the normal code editing features of Eclipse, ADT provides enhancements to the Android 160 development experience that allow you to quickly jump to declarations of various types of resources such 161 as strings or layout files. You can access these enhancements by holding down the control key and 162 clicking on the following items: 163 164 <ul> 165 166 <li>A resource identifier, such as <code>R.id.button1</code>, jumps 167 to the XML definition of the view.</li> 168 169 <li>A declaration in the <code>R.java</code> file, such as <code>public 170 static final int Button01=0x7f050000"</code>, jumps to the corresponding XML definition.</li> 171 172 <li>An activity or service definition in your manifest, such as 173 <code><activity android:name=".TestActivity"></code>, jumps to the corresponding Java class. You can 174 jump from an activity definition (or service definition) into the corresponding Java class.</li> 175 176 <li>You can jump to any value definition (e.g. <code>@string:foo</code>), regardless of 177which XML file 178 "foo" is defined in.</li> 179 180 <li>Any file-based declaration, such as <code>@layout/bar</code>, opens the file.</li> 181 182 <li>Non-XML resources, such as <code>@drawable/icon</code>, launches 183 Eclipse's default application for the given file type, which in this case is an 184 image.</li> 185 186 <li><code>@android</code> namespace resources opens the resources found in 187 the SDK install area.</li> 188 189 <li>Custom views in XML layouts, such as <code><foo.bar.MyView></foo.bar.MyView></code>, 190 or <code><view class="foo.bar.MyView"></code>) jump to the corresponding custom view classes.</li> 191 192 <li>An XML attribute such as <code>@android:string/ok</code> or <code>android.R.string.id</code> in Java code 193 opens the file that declares the strings. The XML tab opens when doing this, not 194 the form-based editor.</li> 195 196 </ul> 197 198 <h2 id="graphical-editor">Graphical Layout Editor</h2> 199 200 <p>ADT provides many features to allow you to design and build your application's user interface. 201 Many of these features are in the graphical layout editor, which you can access by opening one of 202 your application's XML layout files in Eclipse. 203 </p> 204 205 <p>The graphical layout editor is the main screen that you use to visually design and build your 206 UI. It is split up into the following parts:</p> 207 208 <dl> 209 <dt><strong>Canvas</strong></dt> 210 211 <dd>In the middle of the editor is the canvas. It provides the rendered view of your 212 layout and supports dragging and dropping of UI widgets 213 directly from the palette. You can select the platform version used to render the items in 214 the canvas. Each platform version has its own look and feel, which might be the similar to or 215 radically different from another platform version. The canvas renders the appropriate look 216 and feel for the currently selected platform version. 217 This platform version does not need to be the same as the version that your 218 application targets. 219 220 <p>The canvas also provides 221 context-sensitive actions in the layout actions bar, such as adjusting layout margins and 222orientation. 223 The layout actions bar displays available actions depending on the selected UI element in the 224 canvas.</p> 225 </dd> 226 227 <dt><strong>Outline</strong></dt> 228 229 <dd>On the right side of the editor is the outline view. It displays a hierarchical 230 view of your layout where you can do things such as reorder of views. The outline 231 view exposes similar functionality as the canvas but displays your layout in an ordered 232 list instead of a rendered preview.</dd> 233 234 <dt><strong>Palette</strong></dt> 235 236 <dd>On the left side of the editor is the palette. It provides a set of widgets that 237 you can drag onto the canvas. The palette shows rendered previews of the 238 widgets for easy lookup of desired UI widgets.</dd> 239 240 <dt><strong>Configuration Chooser</strong></dt> 241 242 <dd>At the top of the editor is the configuration chooser. 243 It provides options to change a layout's rendering mode or screen type.</dd> 244 </dl> 245 246 <img src="{@docRoot}images/layout_editor.png" alt="graphical layout editor screenshot" 247 height="500" id="layout-editor" name="layout-editor"> 248 249 <p class="img-caption"><strong>Figure 1.</strong> Graphical layout editor</p> 250 251 <h3 id="canvas">Canvas and outline view</h3> 252 253 <div class="sidebox-wrapper"> 254 <div class="sidebox"> 255 <h2>Google I/O Session Video</h2> 256 257 <p>View the segment on the <a href= 258 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=7m16s">canvas and outline view</a> and the 259 <a href="http://www.youtube.com/watch?v=Oq05KqjXTvs#t=11m43s">layout actions bar</a> 260 for more information. 261 </p> 262 </div> 263 </div> 264 265 <p>The canvas is the area where you can drag and drop UI widgets from the palette to design your 266 layout. The canvas offers a rendered preview of your layout depending on factors such as the 267 selected platform version, screen orientation, and currently selected theme that you specify in 268 the <a href="#configuration-chooser">configuration chooser</a>. You can also drag and drop 269 items into the outline view, which displays your layout in a hierarchical list. The outline view 270 exposes much of the same functionality as the canvas but offers another method of organization 271 that is beneficial for ordering and quickly selecting items. When you right-click a specific item 272 in the canvas or outline view, you can access a context-sensitive menu that lets you modify the 273 following attributes of the layout or view:</p> 274 275 <dl> 276 <dt><strong>View and layout properties</strong></dt> 277 278 <dd> 279 When you right-click a view or layout in the canvas or outline view, it brings up a 280 context-sensitive menu that lets you set things such as: 281 282 <ul> 283 <li>ID of the view or layout</li> 284 285 <li>Text of the view</li> 286 287 <li>Layout width</li> 288 289 <li>Layout height</li> 290 291 <li>Properties such as alpha or clickable</li> 292 </ul> 293 </dd> 294 295 <dt><strong>Animation preview and creation</strong></dt> 296 297 <dd> 298 If your layout or view is animated, you can preview the animation directly in the canvas 299 (when you select Android 3.0 or later as the platform version in the configuration chooser). 300 Right-click an item in the canvas and select <strong>Play Animation</strong>. If 301 animation is not associated with item, an option is available in the menu to create one. 302 303 <p>View the segment on the <a href= 304 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=28m30s">animation features</a> for more 305 information.</p> 306 </dd> 307 308 <dt><strong>Extract as Include</strong></dt> 309 310 <dd>You can extract parts of a current layout into its own layout file, 311 which you can then include in any layout with a single line of XML. See <a href= 312 "#extract-as-include">Layout Refactoring Support</a> for more information.</dd> 313 </dl> 314 315 <h4>Other canvas features</h4> 316 317 <p>The canvas has additional features not available in the outline view:</p> 318 319 <ul> 320 321 <li>Edit views with the layout actions bar: The context-sensitive layout actions bar allows you to 322 edit how a view is laid out in your UI. The available actions depend on the currently 323 selected view and its parent layout. Some common actions include 324 toggling the fill mode of the view and specifying margins. For instance, if you select a 325 {@link android.widget.Button} 326 in a {@link android.widget.LinearLayout}, you see actions related to the {@link 327android.widget.LinearLayout}, such as a toggle to switch 328 between horizontal and vertical layout, and a toggle to control whether its children are 329 aligned along their text baseline. You will also see toolbar actions to control the individual 330 layout attributes of the child, such as whether the child should stretch out to match its 331 parent's width and height, a dropdown action to set the child's layout gravity, a button to open 332 a margin editor, and a layout weight editor.</li> 333 334 <li>Edit a nested layout in its current context: If you are editing a layout 335 that includes another layout, you can edit the included layout in the layout that included 336 it.</li> 337 338 <li>Preview drag and drop location: When you drag and drop a UI widget onto the canvas, ruler 339 markers appear showing you the approximate location of the UI widget depending on the 340 type of layout, such as {@link android.widget.RelativeLayout} or {@link 341 android.widget.LinearLayout}.</li> 342 343 <li>Preview animations: You can preview view and layout animations when you select Android 2.1 344 or later for the platform version in the configuration bar.</li> 345 346 <li>Render layouts in real-time: Layouts are rendered as accurately as possible according to 347 the platform version, including the appropriate system and action bars.</li> 348 349 <li>Support for fragments: Fragments can be rendered in the same screen as the layout that 350 includes the fragments.</li> 351 352 </ul> 353 354 <img src="{@docRoot}images/canvas.png" alt="screenshot of the canvas" height="553"> 355 356 <p class="img-caption"><strong>Figure 2.</strong> Canvas portion of the layout editor showing 357 a rendered preview of an application</p> 358 359 <img src= 360 "{@docRoot}images/layout_outline.png" alt="screenshot of the outline view" height="185"> 361 362 <p class="img-caption"><strong>Figure 3.</strong> Outline view showing current layout's structure</p> 363 364 <h3 id="palette">Palette</h3> 365 366 <div class="sidebox-wrapper"> 367 <div class="sidebox"> 368 <h2>Google I/O Session Video</h2> 369 370 <p>View the segment on the <a href= 371 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=7m53s">palette</a> for more information.</p> 372 </div> 373 </div> 374 375 <p>The palette contains the UI widgets that you can drag and drop onto the canvas and add to your 376 layout. The pallete categorizes the widgets and shows rendered previews 377 for easier lookup. The main features of the palette include:</p> 378 379 <ul> 380 <li>Different modes of rendered previews include: icons only, icons and text, tiny previews, 381 small previews, and previews (rendered in real size). Previews are only available for layouts 382 rendered with the latest revisions of Android 2.1 (API Level 7) or later.</li> 383 384 <li>Custom views in your project or library projects are added under custom views 385 category.</li> 386 387 <li>Arrange UI widgets alphabetically or by category.</li> 388 </ul> 389 <img src="{@docRoot}images/palette.png" alt="palette screenshot" height="566"> 390 391 <p class="img-caption"><strong>Figure 4.</strong> Palette showing available UI widgets</p> 392 393 <h3 id="config-chooser">Configuration chooser</h3> 394 395 <div class="sidebox-wrapper"> 396 <div class="sidebox"> 397 <h2>Google I/O Session Video</h2> 398 399 <p>View the segment on the <a href= 400 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=12m51s">configuration chooser</a> for more 401 information.</p> 402 </div> 403 </div> 404 405 406 <p>The configuration chooser allows you to create and configure different configurations of 407 a layout for different situations, such as one for landscape and one for portrait mode. You can 408 set the following options for each configuration of a layout: 409 </p> 410 <ul> 411 <li>Screen type combo box: Predefined screen settings for common device configurations. You 412 can also create your own by selecting <strong>Custom...</strong>.</li> 413 414 <li>Screen orientation combo box: Portrait or Landscape screen orientation.</li> 415 416 <li>Theme combo box: Predefined themes or a custom theme that you have created.</li> 417 418 <li>Platform combo box: Platform version used to render the canvas and palette as well as 419 displaying appropriate themes.</li> 420 421 <li>Custom layout combo boxes: The locale, dock, and time of day combo boxes let you select 422 different versions of the same layout depending on the device's current state. You can 423 create a new version of a layout with the <strong>Create</strong> button.</li> 424 </ul> 425 426 <img src="{@docRoot}images/layout_bar.png" alt= 427 "configuration chooser screenshot" height="50" id="configuration-chooser" name="configuration chooser"> 428 429 <p class="img-caption"><strong>Figure 5.</strong> Configuration chooser</p> 430 431 <h2 id="refactoring">Layout Refactoring Support</h2> 432 433 <div class="sidebox-wrapper"> 434 <div class="sidebox"> 435 <h2>Google I/O Session Video</h2> 436 437 <p>View the segment on <a href= 438 "http://www.youtube.com/watch?v=Oq05KqjXTvs#t=18m00s">refactoring features</a> for a rundown 439of the more important refactoring features.</p> 440 441 </div> 442 </div> 443 444 <p>In both the graphical and XML layout editor, there are many features that help you quickly 445 refactor your layouts. The following list describes the major refactoring support:</p> 446 447 <dl> 448 449 <dt><strong>Change layout</strong></dt> 450 <dd>This lets you change the layout on the fly and re-renders the canvas for you. 451 You can apply this refactoring to any layout and the layout is converted to the new type if 452 possible. In many cases, the opening and closing tags of the layout's XML element are changed 453 along with things such as ID attributes and their references. However, for some supported 454 types, ADT attempts to preserve the layout, such as changing a {@link 455 android.widget.LinearLayout} to a {@link android.widget.RelativeLayout}.</dd> 456 457 <dt><strong>Change widget</strong></dt> 458 <dd>This lets you select one or more widgets and converts them to a new widget type. In 459 addition to changing the element name, it also removes any 460 attributes that are not supported by the new widget type and adds in any mandatory attributes 461 required by the new widget type. If the current ID of a widget includes the 462 current widget type in its ID (such as a <code><Button></code> widget named 463 <code>"button1"</code>), then the ID is changed to match the new widget type and all 464 references are updated.</dd> 465 466 <dt id="extract-as-include"><strong>Extract as include</strong></dt> 467 <dd>This lets you extract views inside of an existing layout into their own separate layout 468 file. An <code>include</code> tag that points to the newly created layout file is inserted 469 into the existing layout file. Right-click the view or layout and select <strong>Extract as 470 Include...</strong>.</dd> 471 472 <dt><strong>Extract string</strong></dt> 473 <dd>Extract strings from either XML or Java files into their own separate resource file.</dd> 474 475 <dt><strong>Extract style</strong></dt> 476 <dd>Extract style-related attributes from a layout and define them in a new 477 <code>styles.xml</code> file. You can select multiple views and this refactoring extracts all 478 of the same styles into one style and assigns that style to all the views that use it.</dd> 479 480 <dt><strong>Wrap-in container</strong></dt> 481 <dd>This lets you select one or more sibling elements and wrap them in a new container. This 482 can be applied to the root element as well, in which case the namespace declaration attributes 483 will be transferred to the new root. This refactoring also transfers <code>layout_</code> 484 attribute references to the new root, For example, suppose you have a {@link android.widget.RelativeLayout}. 485 If other widgets have layout constraints pointing to your widget, wrapping the widget causes 486 these constraints to point to the parent instead.</dd> 487 488 <dt><strong>Quick Assistant</strong></dt> 489 <dd>Provides refactoring suggestions depending on the current context. Press 490 <strong>Ctrl-1</strong> (or <strong>Cmd-1</strong> on 491 Mac) in an editor, and Eclipse provides a list of possible refactorings depending on the 492 context. The Quick Assistant provides fast access to all of the above refactorings, where applicable. 493 For example, if you are editing an XML value and decide you want to extract it out 494 as a string, place the text cursor in the string and press Ctrl-1 to see the refactoring context 495 menu.</dd> 496 </dl> 497 498 499 500 501 502<h2 id="Updating">Updating the ADT Plugin</h2> 503 504<p>From time to time, a new revision of the ADT Plugin becomes available, with 505new features and bug fixes. Generally, when a new revision of ADT is available, 506you should update to it as soon as convenient. </p> 507 508<p>In some cases, a new revision of ADT will have a dependency on a specific 509revision of the Android SDK Tools. If such dependencies exist, you will need to 510update the SDK Tools package of the SDK after installing the new revision of 511ADT. To update the SDK Tools package, use the Android SDK Manager, as 512described in <a href="{@docRoot}sdk/installing/adding-packages.html">Adding SDK Packages</a>.</p> 513 514<p>To learn about new features of each ADT revision and also any dependencies on 515the SDK Tools, see the listings in the <a href="{@docRoot}tools/revisions/index.html">Revisions</a> 516section. To determine the version currently installed, open the 517Eclipse Installed Software window using <strong>Help</strong> 518> <strong>Software Updates</strong> and refer to the version listed for 519"Android Development Tools".</p> 520 521<p>Follow the steps below to check whether an update is available and, if so, 522to install it. </p> 523 524<ol> 525 <li>Select <strong>Help</strong> > <strong>Check for Updates</strong>. 526 <p>If there are no updates available, a dialog will say so and you're done.</p></li> 527 <li>If there are updates available, select Android DDMS, Android Development Tools, 528 and Android Hierarchy Viewer, then click <strong>Next</strong>.</li> 529 <li>In the Update Details dialog, click <strong>Next</strong>.</li> 530 <li>Read and accept the license agreement and then click <strong>Finish</strong>. 531 This will download and install the latest version of Android DDMS and 532 Android Development Tools.</li> 533 <li>Restart Eclipse.</li> 534</ol> 535 536 537<p>If you encounter problems during the update, remove the existing ADT plugin from Eclipse, then 538perform a fresh installation, using the instructions for <a 539href="{@docRoot}sdk/installing/installing-adt.html">Installing the ADT 540Plugin</a>.</p> 541