本文翻译自:Code formatting shortcut in Android Studio

I have started developing with Android Studio . 我已经开始使用Android Studio进行开发了。 In Eclipse I was using Ctrl + Shift + F , but in Android Studio it does not work. 在Eclipse中我使用Ctrl + Shift + F ,但在Android Studio中它不起作用。 It will be different. 会有所不同。

How can I jump to any method in a .java file? 如何跳转到.java文件中的任何方法? I was using Ctrl + O in Eclipse. 我在Eclipse中使用Ctrl + O.

Is it available? 是可用的么? What is the shortcut for code formatting? 代码格式化的快捷方式是什么?


#1楼

参考:https://stackoom.com/question/17ZG7/Android-Studio中的代码格式快捷方式


#2楼

Windows: Ctrl + Alt + L Windows: Ctrl + Alt + L.

Linux: Ctrl + Shift + Alt + L Linux: Ctrl + Shift + Alt + L.

macOS: Option + Command + L macOS: Option + Command + L.

Reference: Key Commands and here are all of the commands for Windows/ Linux users and for Mac users . 参考: 键盘命令 ,以下是Windows / Linux用户和Mac用户的所有命令。


As Rohit faced a problem in Ubuntu with the format code shortcut, this is due to the Ctrl + Alt + L key being used to lock the screen in Ubuntu. 由于Rohit在Ubuntu中遇到了格式代码快捷方式的问题,这是由于Ctrl + Alt + L键用于锁定Ubuntu中的屏幕。

I found that Ubuntu handles this keyboard shortcut first. 我发现Ubuntu首先处理这个键盘快捷键。 So you should bind the Ctrl + Alt + L keyboard shortcut to something else so that it doesn't conflict with Ubuntu. 因此,您应该将Ctrl + Alt + L键盘快捷键绑定到其他内容,以便它不会与Ubuntu冲突。

Steps 脚步

  1. Go to System ToolsSystem SettingsKeyboardShortcuts tab → SystemLock Screen . 进入系统工具系统设置键盘快捷方式选项卡→ 系统锁定屏幕

  2. Select the row New Accelerator... , then press any special key with the Alpha key (eg Shift + L ). 选择New Accelerator ...行,然后按任意特殊键和Alpha键(例如Shift + L )。 You should've successfully changed the keyboard shortcut. 您应该已成功更改键盘快捷键。

  3. Check if the keyboard shortcut now works in Android Studio. 检查键盘快捷键现在是否可以在Android Studio中使用。

Alternative method 替代方法

Ctrl + Alt + Shift + L (to show a dialog) Ctrl + Alt + Shift + L (显示对话框)


You can also use Eclipse shortcuts. 您还可以使用Eclipse快捷方式。

  • Windows and Linux: Go to menu FileSettingsKeymap Windows和Linux:转到菜单文件设置键盘映射
  • macOS: Go to menu PreferencesKeymap and choose Eclipse from the drop-down menu. macOS:转到菜单PreferencesKeymap,然后从下拉菜单中选择Eclipse。

Using MenuBar 使用MenuBar

  • Select code which you want to reformat 选择要重新格式化的代码
  • Click on Code in the menu bar and select Reformat Code as shown in the image below: 单击菜单栏中的“代码” ,然后选择“ 重新格式化代码” ,如下图所示:

In Android studio 3.5, there is problem with rearranging the xml code, it also rearrange the views as well, so need to use these settings first. 在Android studio 3.5中,重新排列xml代码存在问题,它也会重新排列视图,因此需要先使用这些设置。

Settings -> Editor -> Code Style -> XML-> Set From -> Predefined Style > Android. 设置 - >编辑器 - >代码样式 - > XML->设置自 - >预定义样式> Android。


#3楼

Check Keyboard Commands given in the Android Studio Tips & Trick documentation: 检查Android Studio Tips&Trick文档中给出的键盘命令


#4楼

You can also use Eclipse's keyboard shortcuts: just go to menu Preferenceskeymap and choose Eclipse from the dropdown menu. 您还可以使用Eclipse的键盘快捷键:只需转到菜单Preferenceskeymap,然后从下拉菜单中选择Eclipse


The actual path is: menu FileSettingsKeymap (under IDE settings) 实际路径是:菜单文件设置 →键映射 (在IDE设置下)


#5楼

For formatting code in Android Studio on Linux you could instead use Ctrl + Alt + Super + L . 要在Linux上安装Android Studio中的代码,您可以改为使用Ctrl + Alt + Super + L. You could use this and avoid having to change the system shortcut. 您可以使用此功能,避免更改系统快捷方式。 ( Super key is the Windows icon key besides the Alt key). ( 超级键是除Alt键之外的Windows图标键)。


#6楼

The best key where you can find all commands in Eclipse is Ctrl + Shift + L . 在Eclipse中可以找到所有命令的最佳键是Ctrl + Shift + L.

By pressing this you can get all the commands in Eclipse. 通过按此按钮,您可以获得Eclipse中的所有命令。

One important is Ctrl + Shift + O to import and un-import useless imports. 一个重要的是Ctrl + Shift + O来导入和取消导入无用的导入。

Android Studio中的代码格式快捷方式相关推荐

  1. linux android studio 快捷方式,Android studio中的代码格式化快捷方式

    对于在Android Studio中自动格式化Java / xml文件,请使用以下命令: 正如您正在寻找与eclipse一样的单点工作,Android工作室中没有这样的内置功能,但它使您能够通过宏执行 ...

  2. android如何设置自动补,Android Studio 中设置代码块自动补齐

    AS中很多提示键,并不如Eclipse中做的好,需要我们自己去自定义.这里以switch...case为例,讲解一下如何设置代码自动补全. 1.进入settings -->  Editor -- ...

  3. 在Android Studio中进行代码混淆

    此文章来源于http://blog.csdn.net/wenwen091100304/article/details/52802247点击打开链接 在Android APP开发完成后,为了防止APP被 ...

  4. Android Studio中关于9-patch格式图片的编译错误

    最近在编译Android Studio开发的项目中在使用了9宫图后出现了编译错误,尝试了多种方法未能解决,最后仔细查看出错的日志发现,居然是图片的原因,图片中包含有alpah通道所以在执行app:me ...

  5. android studio中清除代码中的无效引用

    平时代码中的无效引用可能不影响APP的运行,但可能会引影 包的大小,所以养成好习惯,每次开发完成后,清理一下 Ctrl+Alt+O 组合键 清除,如果没有效果,看一下是不是登了QQ 快捷键被占用

  6. android 9格式吗,Android Studio中关于9-patch格式图片的编译错误

    C#基础知识回顾-- 反射(3) C#基础知识回顾-- 反射(3)   获取Type对象的构造函数: 前一篇因为篇幅问题因为篇幅太短被移除首页,反射这一块还有一篇"怎样在程序集中使用反射&q ...

  7. Unity与安卓交互 | Unity2019.3版本之后,在Android Studio中写代码导出aar包与Unity中使用交互的方法

  8. android getter不起作用,java - 如何在Android Studio中自动生成getter和setter

    java - 如何在Android Studio中自动生成getter和setter Android Studio中是否有一个快捷方式可以自动生成给定类中的getter和setter? 14个解决方案 ...

  9. Android Studio快捷键之代码提示

    相信很多人在用Eclipse的时候,很习惯的都会把Content Assist设置成.abcd...z,这样每次敲代码的时候都会有自动提示,写起代码来很方便.具体设置如图: 同时,Eclipse中也有 ...

最新文章

  1. LeetCode中等题之两两交换链表中的节点
  2. java 取字段_java – 获取字段的名称
  3. 程序员也需要工匠精神
  4. 不要轻易挑战用户的习惯,否则会被用户打脸!
  5. webstorm常用快捷键
  6. RT-Thread的位图调度算法分析(最新版)
  7. 转载并学习实现三重DES加密解密代码(一)
  8. Python中json和pickle模快dumps()、loads()、dump()、load()序列化和反序列化实例
  9. DQL -- 数据查询语言(查询不会修改数据库表记录)
  10. php抛出和捕获异常,关于php:捕获和重新抛出异常的最佳实践是什么?
  11. python声明匿名函数_举例讲解Python的lambda语句声明匿名函数的用法
  12. MySQL数据库中的删除命令:delete、truncate、drop
  13. swing简单的打字游戏源码
  14. Linux电脑弹出网络认证,linux局域网Dr.COM宽带认证客户端上网指南
  15. 线性代数笔记1.1n阶行列式
  16. 解决window7中浏览器无法上网问题
  17. 对话哈佛大学教授Lukin:量子计算将在我们有生之年普及! | AI英雄
  18. [世界杯] 韩国 vs 多哥 2:1
  19. ftp服务器可以异地传文件吗,FTP图片上传到异地服务器
  20. css中字母数字自动换行

热门文章

  1. Android JetPack ViewModel 源码解析
  2. 【剑指offer-Java版】44扑克牌的顺子
  3. Kotlin特色之object、let、with、run、apply、also函数的使用
  4. 第十、十一周项目四 - 教师兼干部类
  5. 服务器发送退出状态127,WebDriverException:消息:服务chromedriver意外退出。状态代码为:127...
  6. 复制链接到safari浏览器打开_JS实现复制到剪贴板(兼容FF/Chrome/Safari所有浏览器)...
  7. python3.8新特性 逻辑表达式_Python3.8新特性
  8. win10安装MAYA失败,怎么强力卸载删除注册表并重新安装
  9. ZooKeeper原理及使用
  10. shell part2