阿里云服务器免费领卷啦。

捡代码论坛-最全的游戏源码下载技术网站!

 找回密码
 立 即 注 册

QQ登录

只需一步,快速开始

搜索
关于源码区的附件失效或欺骗帖, 处理办法
查看: 3131|回复: 0

50个安卓开发者应该熟悉的Android Studio技巧和资源

[复制链接]

4208

主题

210

回帖

12万

积分

管理员

管理员

Rank: 9Rank: 9Rank: 9

积分
126189
QQ
发表于 2017-3-23 10:35:53 | 显示全部楼层 |阅读模式

本文列举出一些可以提高整体效率的Android Studio技巧和资源。
显然有太多太多这方面的东西,但是为了文章的简洁性,我把它限制在50个以内,希望你能喜欢!
视觉效果
1. Android Logcat的Material颜色主题。

要改变Android Studio的Logcat你需要这样做:进入Preferences (Windows上是Settings / Linux machines) → Editor → Colors & Fonts → Android Logcat,然后为每种类型的log设置前景颜色(foreground)。
我使用的material颜色:
  • Assert #BA68C8
  • Debug #2196F3
  • Error #F44336
  • Info #4CAF50
  • Verbose #BBBBBB
  • Warning #FF9800

注意里面有几个现有的主题,可以直接修改现有主题(不建议),或者点击save  as按钮拷贝一个主题并改名为Material theme Color然后再改变每种类型log的颜色。
2. 防止当前应用崩溃时Logcat清除log。
在Android Monitor面板的右上方点击下拉菜单中的Edit filter configuration:
注意是在工程界面的底部Android Monitor面板,而不是单独的Android Monitor工具中。
3. 使用一个适合自己的代码主题 (IntelliJ / Android Studio).
找到Preferences → Code Style → Java,在Scheme下拉菜单中你可以选择一个代码风格(或者设置一个新的)。
有两个风格值得专门提一下:
你可以按照下面gif图中的做法导入主题:
4. 使用分屏提高效率
要打开这个功能,右键主屏幕的选项卡(tab)选择 Split Vertically / Horizontally。
但是为了尽量提高效率我们需要设置一个自定义的快捷方式。为此找到到Preferences → Keymap,搜索Split Vertically。然后打开一个上下文菜单,点击Add Keyboard Shortcut。
我的分屏(vertical)快捷键设置的是control + alt + v。做法如下面的gif图所示。同样的你还可以为 horizontal split设置快捷键。
5. 无干扰模式
你可以到View → Enter Distraction Free Mode里启用它
在无干扰模式下,编辑器占据了整个IntelliJ IDEA窗口,没有任何tab或者工具按钮。代码居中显示。[IntelliJ Idea Viewing Modes]
6. 使用Live Templates
  • 你可以使用快捷键:cmd + j (Windows / Linux: ctrl + j)。
  • 可以使用已经定义好了的Live Templates,比如Toasts 或者if语句。
  • 可以使用自定义的templates。这里是Reto Meier的一篇不错的参考文章。你也可以参考IntelliJ IDEA的文档。

快捷键以及有用的命令
1.  最有用的命令是搜索命令的命令:cmd + shift + a (Windows / Linux: ctrl + shift + a)。
假设你想关闭当前tab却不知道怎么做,你只需输入close你就可以得到一个正确的快捷键/命令。
2. 选择最近的复制粘贴(管理剪切版):cmd + shift + v (Windows / Linux: ctrl + shift + v)。
默认有5个最近的复制/粘贴元素。
The depth of the Clipboard stack is configured in the Limits section on the Editor page of the Settings dialog box. When the specified number is exceeded, the oldest entry is removed from the list. [Cutting, Copying and Pasting in IntelliJ IDEA]
3. 启用多光标功能:control + g (alt + j for Windows / Linux)。
Bartek Lipinski在Medium上提供了一篇关于这个功能的详细文章。强烈推荐!
4. 打开一个类: cmd + o (Windows / Linux: ctrl + n)。
5. 打开任意文件: cmd + shift + o (Windows / Linux: ctrl + shift + n)。
6.打开symbol:cmd + option + o (Windows / Linux: alt + shift + n)。
7. 跳到实现:cmd + option + b (Windows / Linux:
ctrl + alt + b)。
假如你有一个interface。通过点击接口的名字,然后按下快捷键就可以跳转到这个接口的实现。如果有多个实现会出现下拉选择。
8. 跳转到定义:cmd + b (Windows / Linux: ctrl + b)。
可以让你快速跳转到一个类,方法或者变量被定义的地方。
9. 跳转到类型定义处:control + shift + b (Windows / Linux:
ctrl + shift + b)。
假设你定义了:
Employee employee = new Employee(“Michal”);
当你的插入符号在employee上,这时你按下快捷键,你将跳转到Employee类中。
10. 跳转到super: cmd + u (Windows / Linux: ctrl + u)。
比如,你重写了一些方法,当你的插入符号在方法名上,按下这个快捷键你将跳转到parent的这个方法。
11. Move between tabs: cmd + shift + [ (move left) or cmd + shift + ](move right) (Windows / Linux: alt + ← / →).
12. Move between Design / Text tabs in layout’s view:
control + shift + ← / → (Windows / Linux: alt + shift + ← / →).
13. 关闭当前的tab:cmd + w (Windows / Linux: ctrl + shift + a)。
14. 隐藏所有窗口:cmd + shift + F12 (Windows / Linux:
ctrl + shift + F12)。
15. 最小化 Android Studio instance: cmd + m (Windows / Linux:
ctrl + m)。
16. 格式化代码: cmd + option + l (Windows / Linux:
ctrl + alt + l)。
17. Auto-indent lines: control + option + i (Windows / Linux:
ctrl + alt + i).
18. 实现接口的方法: control + i (Windows / Linux: ctrl + i)。
假设你要实现一个接口。这个快捷键可以让你快速导入这个接口的所有方法。
19. Smart code completion (filters the list of methods and variables by expected type): control + shift + space (Windows / Linux: ctrl + shift + space).
20. 查找: cmd + f (Windows / Linux: ctrl + f)。
21. 查找并替换: cmd + r (Windows / Linux: ctrl + r)。
22. 把一个硬编码的字符串放到资源文件中:option + return (Windows / Linux: alt + enter)。光标必须在这个文字之上时才能使用这个快捷键。看下面的gif图:
插件
资源
这就是本文的内容,请告诉我你知道的技巧和资源。
本文最初发表在我的个人博客


原文地址:
  1. http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2016/1116/6776.html
复制代码



捡代码论坛-最全的游戏源码下载技术网站! - 论坛版权郑重声明:
1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
2、本站所有主题由该帖子作者发表,该帖子作者与捡代码论坛-最全的游戏源码下载技术网站!享有帖子相关版权
3、捡代码论坛版权,详细了解请点击。
4、本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。
5、若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。 我们不承担任何技术及版权问题,且不对任何资源负法律责任。
6、如无法链接失效或侵犯版权,请给我们来信:jiandaima@foxmail.com

回复

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | 立 即 注 册

本版积分规则

技术支持
在线咨询
QQ咨询
3351529868

QQ|手机版|小黑屋|捡代码论坛-专业源码分享下载 ( 陕ICP备15015195号-1|网站地图

GMT+8, 2024-4-27 12:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表