您的位置:首页 > 移动开发 > Android开发

Android Studio / Intellij Tip of the Day

2017-08-24 14:06 453 查看
<1>Android Studio / Intellij Tip of the Day: tools:attribute

If you have ever entered some testing text in a TextView to see how it looks in the previewer, then this is for you.
For any attribute in the xml that has the pattern 'android:something="value"', you can add a new attribute named 'tools:something="value"' and it will be picked up
by the previewer but ignored in your app. Then you can leave default values that makes sense to visualize the layout without impacting the final build. 

Two things that you should check using the tools namespace:
  1) Text that will be set at runtime (so that you don't try to visualize an empty layout)
  2) Stuff that is dynamically changed later (e.g. visibility)

To configure the tools namespace, put this in the root tag of your layout (under the android xmlns):
  xmlns:tools="http://schemas.android.com/tools"



<2>Android Studio / Intellij Tip of the Day: Use the Tab Key in Search Everywhere

Search everywhere is interesting: you only have to double tap the shift key and it will show you matching classes, files, symbols and
even actions! However, if you want to select a method, you'll find it in the third category so you will end up pressing the down key many times.

One cool trick is to use the tab key to navigate quickly between sections. The first tab will get you to the "more" button so that you can expand the current category.
The next time you press the tab key will get you to the next category.



<3>Quick android studio tip: Enable "CamelHumps" words in "Editor->General->Smart Keys" to navigate in method and field names with
the "alt" or "ctrl" key.



<4>Android Studio Tip of the Day: The File Structure Popup

OSX: cmd+f12
Windows/Linux:ctrl+f12 
Other Keymap: Look up the shortcut to the right of this menu:
Navigate → File Structure

The idea here is to show an outline of the current class and navigate in it. The best thing about it is that you can filter using your keyboard. This is a very efficient
way to go to a method you know by name.

Additional tips:
 - You can use camel-case matching when typing to filter the list. Example: typing "oCr" would find "onCreate"
 - You can toggle a checkbox to also show anonymous classes. It could be useful in some cases like if you want to go directly to the onClick method in an OnClickListener.



From:https://plus.google.com/collection/wtO0PB?hl=zh-CN
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: