Android Studio for Operating Systems中的代码格式化快捷方式 [英] Code formatting shortcuts in Android Studio for Operation Systems

查看:90
本文介绍了Android Studio for Operating Systems中的代码格式化快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用 Android Studio 进行开发.在Eclipse中,我使用的是 Ctrl + Shift + F ,但在Android Studio中则无法使用.会有所不同.

I have started developing with Android Studio. In Eclipse I was using Ctrl + Shift + F, but in Android Studio it does not work. It will be different.

如何跳转到.java文件中的任何方法?我在Eclipse中使用 Ctrl + O .

How can I jump to any method in a .java file? I was using Ctrl + O in Eclipse.

可以使用吗?代码格式化的快捷方式是什么?

Is it available? What is the shortcut for code formatting?

推荐答案

Windows: Ctrl + Alt + L

Windows: Ctrl + Alt + L

Linux: Ctrl + Shift + Alt + L

Linux: Ctrl + Shift + Alt + L

macOS:选项 + 命令 + L

macOS: Option + Command + L

参考:键盘命令,以下是所有 Windows/Linux用户

Reference: Key Commands and here are all of the commands for Windows/ Linux users and for Mac users.

由于Rohit在Ubuntu中使用格式代码快捷方式遇到问题,这是由于使用了 Ctrl + Alt + L 键在Ubuntu中锁定屏幕.

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.

我发现Ubuntu首先处理此键盘快捷键.因此,您应该将 Ctrl + Alt + L 键盘快捷方式绑定到其他快捷方式,以免与Ubuntu冲突.

I found that Ubuntu handles this keyboard shortcut first. So you should bind the Ctrl + Alt + L keyboard shortcut to something else so that it doesn't conflict with Ubuntu.

  1. 转到系统工具系统设置键盘快捷方式选项卡→系统锁定屏幕.

选择行 New Accelerator ... ,然后使用Alpha键按任意特殊键(例如 Shift + L ).您应该已经成功更改了键盘快捷键.

Select the row New Accelerator..., then press any special key with the Alpha key (e.g. Shift + L). You should've successfully changed the keyboard shortcut.

检查键盘快捷键现在是否可以在Android Studio中使用.

Check if the keyboard shortcut now works in Android Studio.

替代方法

Ctrl + Alt + Shift + L (显示对话框)

Ctrl + Alt + Shift + L (to show a dialog)


您还可以使用Eclipse快捷方式.


You can also use Eclipse shortcuts.

  • Windows和Linux:转到菜单文件设置键盘映射
  • macOS:转到菜单首选项键盘映射,然后从下拉菜单中选择Eclipse.
  • Windows and Linux: Go to menu FileSettingsKeymap
  • macOS: Go to menu PreferencesKeymap and choose Eclipse from the drop-down menu.
  • 选择要重新格式化的代码
  • 在菜单栏中单击代码,然后选择重新格式化代码,如下图所示:

  • Select code which you want to reformat
  • Click on Code in the menu bar and select Reformat Code as shown in the image below:

在Android Studio 3.5中,重新排列xml代码存在问题,它也会重新排列视图,因此需要首先使用这些设置.

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.

设置->编辑器->代码样式-> XML->设置为->预定义样式> Android.

Settings -> Editor -> Code Style -> XML-> Set From -> Predefined Style > Android.

这篇关于Android Studio for Operating Systems中的代码格式化快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆