Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74056511 authored by smain@google.com's avatar smain@google.com Committed by Android (Google) Code Review
Browse files

Merge "docs:sdk installing file update"

parents 36b8e730 cc3b229b
Loading
Loading
Loading
Loading
+129 −94
Original line number Diff line number Diff line
page.title=Android Studio Tips and Tricks

@jd:body

<div id="qv-wrapper">
<div id="qv">

  <h2>See also</h2>
<ul>
 <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Working+in+Eclipse+Compatibility+Mode" class="external-link"
 >Eclipse Compatibility Mode</a></li>
 <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA" class="external-link"
 >FAQ on Migrating</a></li>
 <li><a href="http://android-developers.blogspot.com/2013/06/adding-backend-to-your-app-in-android.html"
 class="external-link">Adding a Backend to Your App In Android Studio</a></li>
</ul>
  <ol>
    <li><a href="{@docRoot}tools/sdk/index.html">Download Android Studio</a></li>
    <li><a href="http://wiki.jetbrains.net/intellij/Android">IntelliJ IDEA Android Tutorials</a></li>
    <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA">IntelliJ FAQ on migrating to IntelliJ IDEA</a></li>
  </ol>

</div>
</div>

<p>If you're unfamiliar with the IntelliJ IDEA interface, you might be wondering
how to accomplish some common tasks in Android Studio. This page provides some tips
to help you get going.</p>
<p>If you're unfamiliar with using Android Studio and the IntelliJ IDEA interface, this page
provides some tips to help you get started with some of the most common tasks and productivity
enhancements. </p>

<p>For complete user documentation for the IntelliJ IDEA interface
(upon which Android Studio is based), refer to the
<a href="http://www.jetbrains.com/idea/index.html">IntelliJ IDEA documentation</a>.</p>

<div class="figure" style="width:200px">
  <img src="{@docRoot}images/tools/project-layout.png" alt="" />
  <p class="img-caption"><strong>Figure 1.</strong> Gradle project structure</p>
</div>
     <h2>Smart Rendering</h2>
     <p>With smart rendering, Android Studio displays links for quick fixes to rendering errors.
     For example, if you add a button to the layout without specifying the <em>width</em> and
     <em>height</em> atttributes, Android Studio displays the rendering message <em>Automatically
     add all missing attributs</em>. Clicking the message adds the missing attributes to the layout.</p>

<h2 id="Project">Project Structure</h2>

<p>When you create a new project in Android Studio (or
<a href="{@docRoot}sdk/installing/migrate.html">migrate a project from Eclipse</a>),
you'll notice that the project structure appears differently than you may be used to.
As shown in figure 1, almost all your project files are now inside the {@code src/} directory,
including resources and the manifest file.</p>
     <h2> Bitmap rendering in the debugger</h2>
     <p>While debugging, you can now right-click on bitmap variables in your app and invoke
     <em>View Bitmap</em>. This fetches the associated data from the debugged process and renders
     the bitmap in the debugger. </p>
    <p><img src="{@docRoot}images/tools/studio-bitmap-rendering.png" style="width:350px"/></p>
    <p class="img-caption"><strong>Figure 13.</strong> Bitmap Rendering/p>

<p>The new project structure is due to the switch to a Gradle-based build system. This structure
provides more flexibility to the build process and will allow multiple build variants (a feature not
yet fully implemented). Everything still behaves as you expect, but some of the files have moved
around. For the most part, you should need to modify only the files under the {@code src/}
directory. More information about the Gradle project structure is available in the
<a href="http://tools.android.com/tech-docs/new-build-system/user-guide">Gradle
Plugin User Guide</a>.</p>

     <h2>Output window message filtering</h2>
     <p>When checking build results, you can filter messages by <em>message type</em> to quickly
     locate messages of interest.</p>
     <img src="{@docRoot}images/tools/studio-outputwindowmsgfiltering.png" style="width:200px"style="width:200px" />
     <p class="img-caption"><strong>Figure 14.</strong> Filter Build Messages</p>


<h2 id="Basics">Basic Operations</h2>

<p>The following topics describe how to perform
some basic development tasks with Android Studio.</p>
    <h2>Hierarchical parent setting</h2>
    <p>The activity parent can now be set in the Activity Wizard when creating a new
    activity. Setting a <em>hierarchal parent</em> sets the {@code Up} button to automatically
    appear in the app's Action bar when viewing a child activity, so the {@code Up}
    button no longer needs to be manually specified in the <em>menu.xml</em> file.</p>

<p class="note"><strong>Note:</strong> This section lists Android Studio keyboard shortcuts
for the default keymap. To change the default keymap on Windows and Linux, go to
<strong>File</strong> &gt; <strong>Settings</strong> &gt; <strong>Keymap</strong>. To change
the default keymap on Mac OS X, go to <strong>Android Studio</strong> &gt;
<strong>Preferences</strong> &gt; <strong>Keymap</strong>.</p>

<h3>Creating virtual devices</h3>
    <h2>Creating layouts</h2>
    <p>Android Studio offers an advanced layout editor that allows you to drag-and-drop widgets
    into your layout and preview your layout while editing the XML.</p>

    <p>While editing in the <strong>Text</strong> view, you can preview the layout on devices by
    opening the <strong>Preview</strong> pane available on the right side of the window. Within the
    Preview pane, you can modify the preview by changing various options at the top of the pane,
    including the preview device, layout theme, platform version and more. To preview the layout on
    multiple devices simultaneously, select <strong>Preview All Screen Sizes</strong> from the
    device drop-down.</p>
    <p><img src="{@docRoot}images/tools/studio-previewall.png" style="width:350px"/></p>
    <p class="img-caption"><strong>Figure 15.</strong> Preview All Screens/p>

<p>All the capabilities of the <a href="{@docRoot}tools/devices/managing-avds.html">Android
Virtual Device Manager</a> are accessible directly from
the Android Studio interface. Click the <strong>Android Virtual Device Manager</strong>
<img src="{@docRoot}images/tools/avd-manager-studio.png"
style="vertical-align:bottom;margin:0;height:19px" /> in the toolbar to open it and create
new virtual devices for running your app in the emulator.</p>
    <p>You can switch to the graphical editor by clicking <strong>Design</strong> at the
    bottom of the window. While editing in the Design view, you can show and hide the
    widgets available to drag-and-drop by clicking <strong>Palette</strong> on the left side of the
    window. Clicking <strong>Designer</strong> on the right side of the window reveals a panel
    with a layout hierarchy and a list of properties for each view in the layout.</p>


<h3>Installing SDK updates</h3>
     <h2 id="intellij">Working with IntelliJ</h3>

<p>The <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a>
is also accessible to download new Android tools, platforms, and libraries
for your app. Click the <strong>SDK Manager</strong>
<img src="{@docRoot}images/tools/sdk-manager-studio.png"
style="vertical-align:bottom;margin:0;height:19px" /> in the toolbar to open it and check
for updates.</p>
     <p>This section list just a few of the code editing
     practices you should consider using when creating Android Studio apps. </p>

     <p>For complete user documentation for the IntelliJ IDEA interface (upon which Android Studio
     is based), refer to the
     <a href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA documentation</a>.</p>

<h3>Creating new files</h3>

<p>You can quickly add new code and resource files by clicking the appropriate directory in the
<strong>Project</strong> pane and pressing ALT + INSERT on Windows and Linux or COMMAND + N on Mac.
Based on the type of directory selected, Android Studio offers to create the appropriate file
type.</p>

<p>For example, if you select a layout directory, press ALT + INSERT on Windows, and select
<strong>Layout resource file</strong>, a dialog opens so you can name the file (you can exclude
the {@code .xml} suffix) and choose a root view element. The editor then switches to the layout
design editor so you can begin designing your layout.</p>
     <h3><em>Alt + Enter</em> key binding</h3>
     <p>For quick fixes to coding errors, the IntelliJ powered IDE implements the <em>Alt + Enter</em>
     key binding to fix errors (missing imports, variable assignments, missing references, etc) when
     possible, and if not, suggest the most probably solution. </p>


<h3>Creating layouts</h3>
    <h3><em>Ctrl + D</em> key binding</h3>
    <p>The <em>Ctrl + D</em> key binding is great for quickly duplicating code lines or fragments.
    Simply select the desired line or fragment and enter this key binding. </p>

<p>Android Studio offers an advanced layout editor that allows you to drag-and-drop widgets
into your layout and preview your layout while editing the XML.</p>

<p>While editing in the <strong>Text</strong> view, you can preview the layout on devices by opening
the <strong>Preview</strong> pane available on the right side of the window. Within the
Preview pane, you can modify the preview by changing various options at the top of the pane, including
the preview device, layout theme, platform version and more. To preview the layout on multiple
devices simultaneously, select <strong>Preview All Screen Sizes</strong> from the device drop-down.
</p>
    <h3>Navigate menu</h3>
    <p>In case you're not familiar with an API class, file or symbol, the <em>Navigate</em> menu lets
    you jump directly to the class of a method or field name without having to search through
    individual classes. </p>

<p>You can switch to the graphical editor by clicking <strong>Design</strong> at the
bottom of the window. While editing in the Design view, you can show and hide the
widgets available to drag-and-drop by clicking <strong>Palette</strong> on the
left side of the window. Clicking <strong>Designer</strong> on the right side of the window reveals
a panel with a layout hierarchy and a list of properties for each view in the layout.</p>

    <h3>Inspection scopes</h3>
    <p>Scopes set the color of code segments for easy code identification and location. For example,
    you can set a scope to identify all code related to a specific action bar.   </p>



    <h3>External annotations</h3>
    <p>Specify annotations within the code or from an external annotation file. The Android Studio
    IDE keeps track of the restrictions and validates compliance, for example setting the data type
    of a string as not null.</p>


<h3>Debugging</h3>

<p>When you build and run your app with Android Studio, you can view adb and device log messages
(logcat) in the DDMS pane by clicking <strong>Android</strong> at the bottom of the window.</p>
    <h3>Injecting languages</h3>
    <p>With language injection, the Android Studio IDE allows you to work with islands of different
    languages embedded in the source code. This extends the syntax, error highlighting and coding
    assistance to the embedded language. This can be especially useful for checking regular expression
    values inline, and validating XML and SQL statments.</p>

<p>If you want to debug your app with the <a
href="{@docRoot}tools/help/monitor.html">Android Debug Monitor</a>, you can launch it by
clicking <strong>Monitor</strong> <img src="{@docRoot}images/tools/monitor-studio.png"
style="vertical-align:bottom;margin:0;height:19px" /> in the toolbar. The Debug Monitor is where
you can find the complete set of <a href="{@docRoot}tools/debugging/ddms.html">DDMS</a>
tools for profiling your app, controlling device
behaviors, and more. It also includes the Hierarchy Viewer tools to help
<a href="{@docRoot}tools/debugging/debugging-ui.html">optimize your layouts</a>.</p>

    <h3>Code folding</h3>
    <p>This allows you to selectively hide and display sections of the code for readability. For
    example, resource expressions or code for a nested class can be folded or hidden in to one line
    to make the outer class structure easier to read. The inner clas can be later expanded for
    updates. </p>


    <h3>Image and color preview</h3>
    <p>When referencing images and icons in your code, a preview of the image or icon appears
    (in actual size at different densities) in the code margin to help you verify the image or icon
    reference.  Pressing {@code F1} with the preview image or icon selected displays resource asset
    details, such as the <em>dp</em> settings.   </p>


<h2 id="KeyCommands">Keyboard Commands</h2>
    <h3>Quick F1 documentation</h3>
    <p>You can now inspect theme attributes using <strong>View > Quick Documentation</strong>
    (<strong>F1</strong>),
    see the theme inheritance hierarchy, and resolve values for the various attributes.</p>

    <p>If you invoke <strong> View > Quick Documentation</strong> (usually bound to F1) on the theme
    attribute <em>?android:textAppearanceLarge</em>, you will see the theme inheritance hierarchy and
    resolved values for the various attributes that are pulled in.</p>


     <h3>New Allocation Tracker integration in the Android/DDMS window</h3>
     <p>You can now inspect theme attributes using <strong> View > Quick Documentation
     </strong> <code>F1</code>, see the theme inheritance hierarchy, and resolved values for the
     various attributes.</p>
      <img src="{@docRoot}images/tools/studio-allocationtracker.png" style="width:300px" />
      <p class="img-caption"><strong>Figure 16</strong> Allocation Tracker</p>




<h3 id="key-commands">Keyboard Commands</h3>

<p>The following tables list keyboard shortcuts for common operations.</p>

<p class="note"><strong>Note:</strong> This section lists Android Studio keyboard shortcuts
for the default keymap. To change the default keymap on Windows and Linux, go to
<strong>File</strong> &gt; <strong>Settings</strong> &gt; <strong>Keymap</strong>. To change
the default keymap on Mac OS X, go to <strong>Android Studio</strong> &gt;
<strong>Preferences</strong> &gt; <strong>Keymap</strong>.</p>

<p class="note"><strong>Note:</strong> If you're using Mac OS X, update your keymap to use
the Mac OS X 10.5+ version keymaps under <strong>Android Studio > Preferences > Keymap</strong>.</p>



<p class="table-caption"><strong>Table 1.</strong> Programming key commands</p>
<table>
<tr><th>Action</th><th>Android Studio Key Command</th></tr>
@@ -227,7 +255,14 @@ the Mac OS X 10.5+ version keymaps under <strong>Android Studio > Preferences >

</table>

<p>For a complete keymap reference guide, see the <a
href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA</a>
documentation.</p>
<p>For a complete keymap reference guide, see the
<a href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA</a> documentation.</p>


</div>


</div>


+0 −731

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −279

File deleted.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@
<!-- Android Studio menu-->

 <li class="nav-section">
    <div class="nav-section-header"><a href="<?cs var:toroot?>tools/basics/index.html"><span class="en">Android Studio</span></a></div>
    <div class="nav-section-header"><a href="<?cs var:toroot?>tools/studio/index.html"><span class="en">Android Studio</span></a></div>
       <ul>
         <li><a href="<?cs var:toroot ?>tools/basics/studio-tips.html">Tips and Tricks</a> </li>
         <li><a href="<?cs var:toroot ?>sdk/installing/studio-tips.html">Tips and Tricks</a> </li>
       </ul>

 </li><!-- End of Android Studio Basics -->