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