summaryrefslogtreecommitdiffstats
path: root/docs/html/sdk/installing/studio-tips.jd
blob: c3edff639e10369732fb68c62ae4ef1861f197eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
page.title=Android Studio Tips and Tricks
@jd:body

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

  <h2>See also</h2>
  <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 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>


     <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> 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>


     <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>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>


    <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>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>


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

     <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><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 probable solution. </p>


    <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>

    <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>


    <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>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>


    <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>


    <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>. 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>

<tr>
  <td>Command look-up (autocomplete command name)</td>
  <td>CTRL + SHIFT + A</td>
</tr>

<tr>
  <td>Project quick fix</td>
  <td>ALT + ENTER</td>
</tr>

<tr>
  <td>Reformat code</td>
  <td>CTRL + ALT + L (Win)<br>
      OPTION + CMD + L (Mac)</td>
</tr>

<tr>
  <td>Show docs for selected API</td>
  <td>CTRL + Q (Win)<br>
      F1 (Mac)</td>
</tr>

<tr>
  <td>Show parameters for selected method</td>
  <td>CTRL + P</td>
</tr>

<tr>
  <td>Generate method</td>
  <td>ALT + Insert (Win)<br>
      CMD + N (Mac)</td>
</tr>

<tr>
  <td>Jump to source</td>
  <td>F4 (Win)<br>
      CMD + down-arrow (Mac)</td>
</tr>

<tr>
  <td>Delete line</td>
  <td>CTRL + Y (Win)<br>
      CMD + Backspace (Mac)</td>
</tr>

<tr>
  <td>Search by symbol name</td>
  <td>CTRL + ALT + SHIFT + N (Win)<br>
      OPTION + CMD + O (Mac)</td>
</tr>

</table>




<p class="table-caption"><strong>Table 2.</strong> Project and editor key commands</p>
<table>
<tr><th>Action</th><th>Android Studio Key Command</th></tr>

<tr>
  <td>Build</td>
  <td>CTRL + F9 (Win)<br>
      CMD + F9 (Mac)</td>
</tr>

<tr>
  <td>Build and run</td>
  <td>SHIFT + F10 (Win)<br>
      CTRL + R (Mac)</td>
</tr>

<tr>
  <td>Toggle project visibility</td>
  <td>ALT + 1 (Win)<br>
      CMD + 1 (Mac)</td>
</tr>

<tr>
  <td>Navigate open tabs</td>
  <td>ALT + left-arrow; ALT + right-arrow (Win)<br>
      CTRL + left-arrow; CTRL + right-arrow (Mac)</td>
</tr>

</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>


</div>


</div>