Android Studio for 操作系统中的代码格式化快捷方式 [英] Code formatting shortcuts in Android Studio for Operation Systems
问题描述
我已经开始使用
在Android studio 3.5中,重新排列xml代码有问题,它也重新排列视图,所以需要先使用这些设置.
设置 ->编辑器->代码风格 ->XML->设置从 ->预定义样式安卓.
Android Studio 4+ 的更新
从 Android Studio 4+ 开始,您可能会在 Mac 上遇到快捷方式问题.更新到 Android studio 4 后快捷方式不起作用,在 Mac 上?对此有答案.
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.
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
Linux: Ctrl + Shift + Alt + L
macOS: Option + Command + L
Reference: Key Commands and here are all of the commands for Windows/ Linux users and for Mac users.
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.
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.
Steps
Go to System Tools → System Settings → Keyboard → Shortcuts tab → System → Lock Screen.
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.
Check if the keyboard shortcut now works in Android Studio.
Alternative method
Ctrl + Alt + Shift + L (to show a dialog)
You can also use Eclipse shortcuts.
- Windows and Linux: Go to menu File → Settings → Keymap
- macOS: Go to menu Preferences → Keymap and choose Eclipse from the drop-down menu.
Using 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.
Settings -> Editor -> Code Style -> XML-> Set From -> Predefined Style > Android.
Update for Android Studio 4+
Since Android Studio 4+, you might face issue shortcuts on mac. Shortcuts not working after updating to Android studio 4, in Mac? have an answer for that.
这篇关于Android Studio for 操作系统中的代码格式化快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!