Android Studio小技巧

Android Studio Tips of the Day里面一共有八十几个。大家可以去查看完整的。而且是持续更新状态中。很有用(记得安全上网,翻墙哦。)

1、tools:attribute

如果你需要查看写的TextView在有文字时候的预览情况。那么这个就是为你准备的。使用'tools:something="value"'这个值会显示在预览时候,但是在软件真正运行的时候不会出现这个内容。
只需要二步就可以:

  • 在根布局中添加xmlns:tools="http://schemas.android.com/tools"

  • 在TextView中使用'tools:something="value"'属性

(这个太有用了!!!我以前每次写布局预览效果都用android:text = "XXX",然后程序弄完还得去删。太傻了!!!)

2、Extract Resource

比如你在布局文件或者代码文件中直接写了某个String字符串或者某个dimen数值,而不是引用资源文件,那难道还要我再去打开相应的String.xml或者dimen.xml文件去添加,然后这边的布局文件或者代码文件中再去修改使用引用?答案当然是NO。
* Mac:选中那个值,然后option+enter键选择Extract String/Dimension Resource 。
* Win: alt+enter键选择Extract String/Dimension Resource 。

3、Toggle between text/design mode

Design查看和Text编辑之间切换
* mac用Control + Shift +左/右
* Windows和Linux上用ALT + SHIFT +左/右

4、CamelHumps

在"Editor->General->Smart Keys"中启动"CamelHumps"功能选项,就可以在连在一起的几个大写为首的单词间快速切换。
* Mac上是option+左右键。
* win上为 "alt" or "ctrl" 键。(这里会有个bug,开启后,比如你的变量名是几个单词,比如是isSuccess,这时候你双击想选中这个变量就发现不能全部选中,就变成选中Success了。)

5、Close Others

当Android Studio开了很多文件,想要留下当前文件,然后关闭其他文件,通常做法是右键,然后选择Close Others。实际上只需要
* Mac:按住option,然后鼠标点击要留下来的文件的关闭按钮,然后其他的就都关闭了
* Win:按住alt.

6、The Navigation Bar

导航栏是在IDE顶部的“面包屑”。
这表明你的路径添加到当前文件,但你也可以用它来导航和/或采取对文件和文件夹的操作。

  • 您可以导航到父母的子文件夹或找到兄弟类
  • 您可以轻松地创建使用代码生成快捷方式(CMD + N / ALT +插入)新文件
  • 事实上,你可以在项目视图通过右键点击做任何事情
  • 你可以隐藏这个导航栏。通过快捷键来显示。可以让Android Studio的屏幕显示内容可以更多。

7、Open Source in New Window

你能让当前打开的文件,以另起一个窗口来进行显示。
* Mac:shift +F4(有些人F4可能是系统快捷键,那就多加一个fn)
* Win:shift+F4

8、Override Methods

我们可能想重载某个父类的方法,但是一时间忘记了这个方法的名字,可以快捷键调出所有可重载的方法,进行选择。
* Mac:control + o
* Win:ctrl + o

9、Edit Regex

描述:使用Java编写正则表达式是一件很困难的事,主要原因是:

  • 你必须得避开反斜杠;
  • 说实话,正则很难;
  • 看第二条。
    IDE能帮我们干点啥呢?当然是一个舒服的界面来编写和测试正则啦~ - 快捷键:Alt + Enter → check regexp

10、The Switcher

打开的文件太多。怎么快速切换文件?
* Mac : control + tab
* win: ctrl + tab

评论

  • game development回复

    I'm still learning from you, as I'm trying to reach my goals. I absolutely enjoy reading everything that is written on your blog.Keep the posts coming. I enjoyed it!

  • ice cream recipes回复

    Wow! Thank you! I continually wanted to write on my blog something like that. Can I implement a portion of your post to my website?

  • drywall repair回复

    I have been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.

  • games回复

    Very good written story. It will be beneficial to anybody who employess it, including yours truly :). Keep up the good work - looking forward to more posts.

  • universalsitesupplies.co.uk回复

    Wow! Thank you! I continually needed to write on my site something like that. Can I take a portion of your post to my website?

  • universalsitesupplies.co.uk回复

    It’s actually a great and useful piece of information. I’m glad that you shared this useful information with us. Please keep us up to date like this. Thanks for sharing.

  • M88回复

    Definitely believe that which you stated. Your favorite justification seemed to be on the internet the easiest thing to be aware of. I say to you, I certainly get irked while people think about worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

  • MoisesGergo回复

    viagra 100mg 4

    <a href=http://buycxviagra.com/>order viagra</a>

    <a href="http://buycxviagra.com/">viagra online</a>

    buy viagra online purchase

  • dog food回复

    Hello colleagues, its wonderful piece of writing concerning cultureand completely explained, keep it up all the time.|

  • Business回复

    You actually make it seem really easy with your presentation but I to find this topic to be actually something which I believe I would by no means understand. It kind of feels too complex and extremely huge for me. I am taking a look forward to your subsequent publish, I¡¦ll attempt to get the grasp of it!

  • chennai news today回复

    check below, are some entirely unrelated internet websites to ours, nonetheless, they may be most trustworthy sources that we use

  • Information technology回复

    I'm so happy to read this. This is the type of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this greatest doc.

  • Dog Walker Ottawa回复

    Hiya, I am really glad I've found this information. Today bloggers publish only about gossips and net and this is really frustrating. A good web site with interesting content, this is what I need. Thank you for keeping this web site, I'll be visiting it. Do you do newsletters? Cant find it.