代码格式化快捷方式在Android studio中

时间:2022-12-03 20:50:44

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.

我开始使用Android Studio进行开发。在eclipse中,我使用的是Ctrl+Shift+F,但在Android studio中它不工作,它将会是不同的。

How can I jump to any method in .java. I was using Ctrl+O in eclipse.

如何跳转到.java中的任何方法。我在eclipse中使用了Ctrl+O。

Is it available? Can any one tell me that shortcut for code formatting?

它可用吗?有人能告诉我代码格式化的快捷方式吗?

19 个解决方案

#1


1349  

Win

赢得

Ctrl + Alt + L

Ctrl + Alt + L。

Linux:

Linux:

Ctrl + Shift + Alt + L

Ctrl + Shift + Alt + L

Mac:

麦克:

Option + Command + L

选项+命令+ L

Reference : Key Commands and here is full commands for Windows/ Linux users and for Mac users

参考:关键命令,这里是Windows/ Linux用户和Mac用户的完整命令


Update for Ubuntu As Rohit faced the problem in Ubuntu to format code shortcut, because the Ctrl + Alt + L key is used to lock the screen in Ubuntu.

由于Rohit在Ubuntu中遇到了格式化代码快捷方式的问题,所以在Ubuntu中使用Ctrl + Alt + L键来锁定屏幕。

I found that Ubuntu which handles the key event first. So try to change the Ctrl + Alt + L action in Ubuntu just to be sure.

我发现Ubuntu首先处理关键事件。所以试着在Ubuntu中改变Ctrl + Alt + L的动作来确定。

Steps are :-

步骤是:

Go to System Tools -> System Settings -> Keyboard -> Shortcuts Tab -> System -> Lock Screen

进入系统工具->系统设置->键盘->快捷键->系统->锁屏

Select the row New Accelerator... will be visible then press any Special key with Alpha key (like Shift + L). You changed the key shortcuts.

选择行新加速器…将是可见的,然后按任何特殊的键与阿尔法键(如Shift + L)。你改变了键的快捷方式。

Now check format key in Studio.

现在在Studio中检查格式键。

Alternatively

另外

Ctrl + Alt + Shift + L (for a dialog)

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


Update came from Henry Chuang, and also in another answer given by user2340612.

更新来自Henry Chuang,以及user2340612给出的另一个答案。

You can also use Eclipse shortcuts. Windows and Linux, go to File > Settings > Keymap , Mac OS X, go to > Preferences > Keymap and choose Eclipse from the dropdown menu.

您还可以使用Eclipse快捷方式。进入文件>设置> Keymap, Mac OS X,进入>首选项> Keymap,从下拉菜单中选择Eclipse。

#2


106  

You can also use Eclipse's keyboard shortcuts: just go on preferences->keymap and choose eclipse from the dropdown menu.

您还可以使用Eclipse的键盘快捷键:只需进入preferences->keymap,并从下拉菜单中选择Eclipse。

EDIT

The actual path is: File->Settings->(under IDE settings)->Keymap (thanks to @Dhinakaran Thennarasu)

实际路径是:File->设置->(在IDE设置下)->Keymap(感谢@Dhinakaran Thennarasu)

#3


66  

Check Keyboard Commands given in the Studio Tips & Trick documentation.

查看Studio提示和技巧文档中给出的键盘命令。

代码格式化快捷方式在Android studio中

#4


26  

Just select the code and

只要选择代码

  • on Windows do Ctrl + Alt + L

    在Windows上Ctrl + Alt + L。

  • on Linux do Ctrl + Windows Key + Alt + L

    在Linux上按Ctrl + Windows键+ Alt + L

  • on Mac do CMD + Alt + L

    在Mac上做CMD + Alt + L

This solution from junaidp

这个解决方案从junaidp

#5


14  

For formatting code on Android Studio on Linux you could instead use 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).

对于Linux上的Android Studio的格式化代码,您可以使用CTRL+ALT+SUPER+L。您可以使用它,并避免必须更改系统快捷方式。(SUPER key除了ALT键外,还是windows图标键)

#6


10  

for code formatting in Android Studio
CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)

用于Android Studio中的代码格式化,CTRL + ALT + L (Win/ Linux)选项+ CMD + L (Mac)

user can also use Eclipse's keyboard shortcuts: just go on Setting>>preferences->keymap and choose eclipse(or any one you like) from the dropdown menu.

用户还可以使用Eclipse的键盘快捷键:只需设置>>首选项——>keymap,然后从下拉菜单中选择Eclipse(或任何你喜欢的)。

#7


10  

You will have to apply all ecplise shortcut with Android Studio before use of all those shortcut.

在使用所有这些快捷方式之前,您必须在Android Studio中应用所有ecplise快捷方式。

Procedure: Steps:

步骤:步骤:

Setting -> KeyMap -> Select Eclipse -> Apply -> OK

Now you can use all ecplise shortcut in Android Studio..

现在您可以在Android Studio中使用所有ecplise快捷方式。

Have some snapshots here.

这里有一些快照。

代码格式化快捷方式在Android studio中代码格式化快捷方式在Android studio中

#8


8  

Check this. Also you can change it as per your preference.

检查这个。你也可以根据你的喜好改变它。

代码格式化快捷方式在Android studio中

代码格式化快捷方式在Android studio中

#9


6  

Just to add to @user2340612 answer to switch keymaps to eclipse, the path for Android Studio 1.0.1 is:

只需添加@user2340612,将keymaps切换到eclipse, Android Studio 1.0.1的路径为:

File -> Settings -> Keymap (Under Editor option) -> Keymaps = Eclipse

#10


5  

Ctrl+Alt+L might conflict with Lock Screen shortcut in Ubuntu. In such case you can change the keyboard shortcut for Reformatting Code as follows:

在Ubuntu中,Ctrl+Alt+L可能会与锁屏快捷方式发生冲突。在这种情况下,您可以更改重新格式化代码的键盘快捷方式如下:

File-> Settings-> IDE Settings-> Keymap

文件->设置-> IDE设置->密钥映射

Search for Reformat Code and change the keyboard shortcut.

搜索重新格式化代码并更改键盘快捷方式。

#11


5  

Really, I went to this thread because of my Ubuntu locks screen after this shortcut Ctrl + Alt + L. So if you are have the same problem just go to the Settings - Keyboard - Shortcuts - System and change the default shortcut for the "Lock screen".

真的,我去这个线程,因为我的Ubuntu锁定屏幕在快捷方式Ctrl + Alt + l之后,所以如果你有同样的问题,去到设置-键盘-快捷键-系统,改变“锁定屏幕”的默认快捷方式。

#12


5  

For Auto Formatting your Java/xml files in Android Studio use following commands:

对于在Android Studio中自动格式化Java/xml文件,请使用以下命令:

As you are looking for a single point to go with your work as eclipse did, there is no such built in functionality in Android studio but it gives you the ability to do it through Macro, Follow these steps:

正如eclipse所做的那样,您正在寻找一个单独的点来完成您的工作,Android studio中没有这种内置的功能,但它提供了通过宏完成工作的能力,请遵循以下步骤:

In studio open any of your source code file.

在studio中打开任何源代码文件。

Press Ctrl + Alt + O This is used to find/optimize unused import.

按Ctrl + Alt + O来查找/优化未使用的导入。

If a dialog open select 'Dont show it again' and hit Run.

如果打开一个对话框,选择“不要再显示它”并点击“运行”。

Go to Edit > Macros > Start Macro Recording.

转到编辑>宏>开始宏录制。

Press Ctrl + Alt + O.

按Ctrl + Alt + O键。

Press Ctrl + Alt + L. This formats your code. (Shift+ctrl+Alt+L for ubuntu).

按Ctrl + Alt + l,这将格式化你的代码。(Shift + ctrl + Alt + L ubuntu)。

Press Ctrl + S ,This saves your file;)

按Ctrl + S,可以保存文件;

Go to Edit > Macros > Stop Macro Recording.

转到编辑>宏>停止宏记录。

Save this created macro with name for instance:“Auto Formatting".

将创建的宏保存为“自动格式化”。

Boom, You have now successfully created your Macro, Now just add/assign a shortcut to it:

现在,您已经成功创建了宏,现在只需添加/分配一个快捷方式:

Open Preferences.

开放的偏好。

Search in the left bar for Keymap.

在左栏中搜索关键图。

In the right hand pane, click in the search bar and type the name of your saved macro("Auto Formatting".)

在右手窗格中,单击搜索栏,输入保存的宏的名称(“自动格式化”)。

Double click on your item. There might be two, it doesn’t matter which one you click on.

双击你的项目。可能有两个,你点击哪个并不重要。

Click Add Keyboard Shortcut.

单击Add键盘快捷键。

Set your keyboard shortcut to Ctrl + S.

将键盘快捷键设置为Ctrl + S。

Finally,Confirm overriding Ctrl + S to be your new macro.

最后,确认重写Ctrl + S为新的宏。

#13


4  

For those who are wondering about the alignment issue inside bracket. JetBrains has this as in their issue tracking.

对于那些想知道括号内对齐问题的人。JetBrains在他们的问题跟踪中也有这个功能。

here is the answer:

这里是回答:

https://*.com/a/28225339/3281140

https://*.com/a/28225339/3281140

#14


3  

I think is clear that for code formatting in Android Studio the combination keys are:

我认为在Android Studio中,对于代码格式,组合键是:

CTRL + ALT + L (Win/ Linux)

CTRL + ALT + L (Win/ Linux)

OPTION + CMD + L (Mac)

选项+ CMD + L (Mac)

However, we forgot to answer about the Jumping into the method. Well to go into any declaration/implementation there three ways:

然而,我们忘记回答关于跳进方法的问题。我们可以用三种方式来阐述任何声明/实施:

  1. Goto Declaration
  2. Goto宣言

CTRL + B or CTRL + CLICK (Win/ Linux)

CTRL + B或CTRL + CLICK (Win/ Linux)

CMD + B or CMD + CLICK (Mac)

CMD + B或CMD + CLICK (Mac)

  1. Goto Implementation
  2. 转到实现

These commands show a list of all the classes/interfaces that are implementing the selected class/interface. On variables, it has the same effect as Goto Declaration.

这些命令显示了实现所选类/接口的所有类/接口的列表。对于变量,它具有与Goto声明相同的效果。

CTRL + ALT + B (Win/ Linux)

CTRL + ALT + B (Win/ Linux)

CMD + ALT + B (Mac)

CMD + ALT + B (Mac)

  1. Goto Type Declaration
  2. Goto类型声明

These shortcuts will go into the declaration of the “AnyClass” class.

这些快捷方式将进入“AnyClass”类的声明。

CTRL + SHIFT + B (Win/ Linux)

CTRL + SHIFT + B (Win/ Linux)

CTRL + SHIFT + B (Mac)

CTRL + SHIFT + B (Mac)

Additionally, there is a shortcut for Goto the Super Class. This will open the parent of the current symbol. Pretty much the opposite of Goto Implementation. For overridden methods, it will open its parent implementation.

此外,还有一个超类Goto的快捷方式。这将打开当前符号的父元素。几乎与后端实现相反。对于重写的方法,它将打开其父实现。

CTRL + U (Win/ Linux)

CTRL + U (Win/ Linux)

CMD + U (Mac)

CMD + U(Mac)

#15


2  

The shortcut that worked for me is

我的捷径是

SHIFT+ALT+CMD+L

SHIFT + ALT + CMD + L

You can optimize imports to remove the ones you don't use, and auto import the new classes.

您可以优化导入以删除不使用的导入,并自动导入新类。

代码格式化快捷方式在Android studio中

代码格式化快捷方式在Android studio中

#16


1  

Try this.

试试这个。

  • On Windows do Ctrl + Alt + L
  • 在Windows上按Ctrl + Alt + L键
  • On Linux do Ctrl + Shift + Alt + L for dialog to open and then reformat.
  • 在Linux上按Ctrl + Shift + Alt + L打开对话框,然后重新格式化。
  • On Mac do CMD + Alt + L
  • 在Mac上做CMD + Alt + L。

Note: Here many answers for Linux is just Ctrl + Alt + L which is wrong. In Linux, doing Ctrl + Alt + L locks the system.

注意:这里Linux的很多答案是Ctrl + Alt + L,这是错误的。在Linux中,按Ctrl + Alt + L锁定系统。

#17


1  

It's Ctrl + Alt + L for Windows. For a complete list of keyboard shortcuts please take a look at the user manual: https://developer.android.com/studio/intro/keyboard-shortcuts.html

它是Ctrl + Alt + L表示Windows。要获得完整的键盘快捷键列表,请参阅用户手册:https://developer.android.com/studio/intro/keyboard-shortcuts.html

#18


-1  

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导入无用的导入。

#19


-1  

You can use the following shortcut for code formatting: Ctrl+Alt+L

可以使用以下快捷方式进行代码格式化:Ctrl+Alt+L

#1


1349  

Win

赢得

Ctrl + Alt + L

Ctrl + Alt + L。

Linux:

Linux:

Ctrl + Shift + Alt + L

Ctrl + Shift + Alt + L

Mac:

麦克:

Option + Command + L

选项+命令+ L

Reference : Key Commands and here is full commands for Windows/ Linux users and for Mac users

参考:关键命令,这里是Windows/ Linux用户和Mac用户的完整命令


Update for Ubuntu As Rohit faced the problem in Ubuntu to format code shortcut, because the Ctrl + Alt + L key is used to lock the screen in Ubuntu.

由于Rohit在Ubuntu中遇到了格式化代码快捷方式的问题,所以在Ubuntu中使用Ctrl + Alt + L键来锁定屏幕。

I found that Ubuntu which handles the key event first. So try to change the Ctrl + Alt + L action in Ubuntu just to be sure.

我发现Ubuntu首先处理关键事件。所以试着在Ubuntu中改变Ctrl + Alt + L的动作来确定。

Steps are :-

步骤是:

Go to System Tools -> System Settings -> Keyboard -> Shortcuts Tab -> System -> Lock Screen

进入系统工具->系统设置->键盘->快捷键->系统->锁屏

Select the row New Accelerator... will be visible then press any Special key with Alpha key (like Shift + L). You changed the key shortcuts.

选择行新加速器…将是可见的,然后按任何特殊的键与阿尔法键(如Shift + L)。你改变了键的快捷方式。

Now check format key in Studio.

现在在Studio中检查格式键。

Alternatively

另外

Ctrl + Alt + Shift + L (for a dialog)

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


Update came from Henry Chuang, and also in another answer given by user2340612.

更新来自Henry Chuang,以及user2340612给出的另一个答案。

You can also use Eclipse shortcuts. Windows and Linux, go to File > Settings > Keymap , Mac OS X, go to > Preferences > Keymap and choose Eclipse from the dropdown menu.

您还可以使用Eclipse快捷方式。进入文件>设置> Keymap, Mac OS X,进入>首选项> Keymap,从下拉菜单中选择Eclipse。

#2


106  

You can also use Eclipse's keyboard shortcuts: just go on preferences->keymap and choose eclipse from the dropdown menu.

您还可以使用Eclipse的键盘快捷键:只需进入preferences->keymap,并从下拉菜单中选择Eclipse。

EDIT

The actual path is: File->Settings->(under IDE settings)->Keymap (thanks to @Dhinakaran Thennarasu)

实际路径是:File->设置->(在IDE设置下)->Keymap(感谢@Dhinakaran Thennarasu)

#3


66  

Check Keyboard Commands given in the Studio Tips & Trick documentation.

查看Studio提示和技巧文档中给出的键盘命令。

代码格式化快捷方式在Android studio中

#4


26  

Just select the code and

只要选择代码

  • on Windows do Ctrl + Alt + L

    在Windows上Ctrl + Alt + L。

  • on Linux do Ctrl + Windows Key + Alt + L

    在Linux上按Ctrl + Windows键+ Alt + L

  • on Mac do CMD + Alt + L

    在Mac上做CMD + Alt + L

This solution from junaidp

这个解决方案从junaidp

#5


14  

For formatting code on Android Studio on Linux you could instead use 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).

对于Linux上的Android Studio的格式化代码,您可以使用CTRL+ALT+SUPER+L。您可以使用它,并避免必须更改系统快捷方式。(SUPER key除了ALT键外,还是windows图标键)

#6


10  

for code formatting in Android Studio
CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)

用于Android Studio中的代码格式化,CTRL + ALT + L (Win/ Linux)选项+ CMD + L (Mac)

user can also use Eclipse's keyboard shortcuts: just go on Setting>>preferences->keymap and choose eclipse(or any one you like) from the dropdown menu.

用户还可以使用Eclipse的键盘快捷键:只需设置>>首选项——>keymap,然后从下拉菜单中选择Eclipse(或任何你喜欢的)。

#7


10  

You will have to apply all ecplise shortcut with Android Studio before use of all those shortcut.

在使用所有这些快捷方式之前,您必须在Android Studio中应用所有ecplise快捷方式。

Procedure: Steps:

步骤:步骤:

Setting -> KeyMap -> Select Eclipse -> Apply -> OK

Now you can use all ecplise shortcut in Android Studio..

现在您可以在Android Studio中使用所有ecplise快捷方式。

Have some snapshots here.

这里有一些快照。

代码格式化快捷方式在Android studio中代码格式化快捷方式在Android studio中

#8


8  

Check this. Also you can change it as per your preference.

检查这个。你也可以根据你的喜好改变它。

代码格式化快捷方式在Android studio中

代码格式化快捷方式在Android studio中

#9


6  

Just to add to @user2340612 answer to switch keymaps to eclipse, the path for Android Studio 1.0.1 is:

只需添加@user2340612,将keymaps切换到eclipse, Android Studio 1.0.1的路径为:

File -> Settings -> Keymap (Under Editor option) -> Keymaps = Eclipse

#10


5  

Ctrl+Alt+L might conflict with Lock Screen shortcut in Ubuntu. In such case you can change the keyboard shortcut for Reformatting Code as follows:

在Ubuntu中,Ctrl+Alt+L可能会与锁屏快捷方式发生冲突。在这种情况下,您可以更改重新格式化代码的键盘快捷方式如下:

File-> Settings-> IDE Settings-> Keymap

文件->设置-> IDE设置->密钥映射

Search for Reformat Code and change the keyboard shortcut.

搜索重新格式化代码并更改键盘快捷方式。

#11


5  

Really, I went to this thread because of my Ubuntu locks screen after this shortcut Ctrl + Alt + L. So if you are have the same problem just go to the Settings - Keyboard - Shortcuts - System and change the default shortcut for the "Lock screen".

真的,我去这个线程,因为我的Ubuntu锁定屏幕在快捷方式Ctrl + Alt + l之后,所以如果你有同样的问题,去到设置-键盘-快捷键-系统,改变“锁定屏幕”的默认快捷方式。

#12


5  

For Auto Formatting your Java/xml files in Android Studio use following commands:

对于在Android Studio中自动格式化Java/xml文件,请使用以下命令:

As you are looking for a single point to go with your work as eclipse did, there is no such built in functionality in Android studio but it gives you the ability to do it through Macro, Follow these steps:

正如eclipse所做的那样,您正在寻找一个单独的点来完成您的工作,Android studio中没有这种内置的功能,但它提供了通过宏完成工作的能力,请遵循以下步骤:

In studio open any of your source code file.

在studio中打开任何源代码文件。

Press Ctrl + Alt + O This is used to find/optimize unused import.

按Ctrl + Alt + O来查找/优化未使用的导入。

If a dialog open select 'Dont show it again' and hit Run.

如果打开一个对话框,选择“不要再显示它”并点击“运行”。

Go to Edit > Macros > Start Macro Recording.

转到编辑>宏>开始宏录制。

Press Ctrl + Alt + O.

按Ctrl + Alt + O键。

Press Ctrl + Alt + L. This formats your code. (Shift+ctrl+Alt+L for ubuntu).

按Ctrl + Alt + l,这将格式化你的代码。(Shift + ctrl + Alt + L ubuntu)。

Press Ctrl + S ,This saves your file;)

按Ctrl + S,可以保存文件;

Go to Edit > Macros > Stop Macro Recording.

转到编辑>宏>停止宏记录。

Save this created macro with name for instance:“Auto Formatting".

将创建的宏保存为“自动格式化”。

Boom, You have now successfully created your Macro, Now just add/assign a shortcut to it:

现在,您已经成功创建了宏,现在只需添加/分配一个快捷方式:

Open Preferences.

开放的偏好。

Search in the left bar for Keymap.

在左栏中搜索关键图。

In the right hand pane, click in the search bar and type the name of your saved macro("Auto Formatting".)

在右手窗格中,单击搜索栏,输入保存的宏的名称(“自动格式化”)。

Double click on your item. There might be two, it doesn’t matter which one you click on.

双击你的项目。可能有两个,你点击哪个并不重要。

Click Add Keyboard Shortcut.

单击Add键盘快捷键。

Set your keyboard shortcut to Ctrl + S.

将键盘快捷键设置为Ctrl + S。

Finally,Confirm overriding Ctrl + S to be your new macro.

最后,确认重写Ctrl + S为新的宏。

#13


4  

For those who are wondering about the alignment issue inside bracket. JetBrains has this as in their issue tracking.

对于那些想知道括号内对齐问题的人。JetBrains在他们的问题跟踪中也有这个功能。

here is the answer:

这里是回答:

https://*.com/a/28225339/3281140

https://*.com/a/28225339/3281140

#14


3  

I think is clear that for code formatting in Android Studio the combination keys are:

我认为在Android Studio中,对于代码格式,组合键是:

CTRL + ALT + L (Win/ Linux)

CTRL + ALT + L (Win/ Linux)

OPTION + CMD + L (Mac)

选项+ CMD + L (Mac)

However, we forgot to answer about the Jumping into the method. Well to go into any declaration/implementation there three ways:

然而,我们忘记回答关于跳进方法的问题。我们可以用三种方式来阐述任何声明/实施:

  1. Goto Declaration
  2. Goto宣言

CTRL + B or CTRL + CLICK (Win/ Linux)

CTRL + B或CTRL + CLICK (Win/ Linux)

CMD + B or CMD + CLICK (Mac)

CMD + B或CMD + CLICK (Mac)

  1. Goto Implementation
  2. 转到实现

These commands show a list of all the classes/interfaces that are implementing the selected class/interface. On variables, it has the same effect as Goto Declaration.

这些命令显示了实现所选类/接口的所有类/接口的列表。对于变量,它具有与Goto声明相同的效果。

CTRL + ALT + B (Win/ Linux)

CTRL + ALT + B (Win/ Linux)

CMD + ALT + B (Mac)

CMD + ALT + B (Mac)

  1. Goto Type Declaration
  2. Goto类型声明

These shortcuts will go into the declaration of the “AnyClass” class.

这些快捷方式将进入“AnyClass”类的声明。

CTRL + SHIFT + B (Win/ Linux)

CTRL + SHIFT + B (Win/ Linux)

CTRL + SHIFT + B (Mac)

CTRL + SHIFT + B (Mac)

Additionally, there is a shortcut for Goto the Super Class. This will open the parent of the current symbol. Pretty much the opposite of Goto Implementation. For overridden methods, it will open its parent implementation.

此外,还有一个超类Goto的快捷方式。这将打开当前符号的父元素。几乎与后端实现相反。对于重写的方法,它将打开其父实现。

CTRL + U (Win/ Linux)

CTRL + U (Win/ Linux)

CMD + U (Mac)

CMD + U(Mac)

#15


2  

The shortcut that worked for me is

我的捷径是

SHIFT+ALT+CMD+L

SHIFT + ALT + CMD + L

You can optimize imports to remove the ones you don't use, and auto import the new classes.

您可以优化导入以删除不使用的导入,并自动导入新类。

代码格式化快捷方式在Android studio中

代码格式化快捷方式在Android studio中

#16


1  

Try this.

试试这个。

  • On Windows do Ctrl + Alt + L
  • 在Windows上按Ctrl + Alt + L键
  • On Linux do Ctrl + Shift + Alt + L for dialog to open and then reformat.
  • 在Linux上按Ctrl + Shift + Alt + L打开对话框,然后重新格式化。
  • On Mac do CMD + Alt + L
  • 在Mac上做CMD + Alt + L。

Note: Here many answers for Linux is just Ctrl + Alt + L which is wrong. In Linux, doing Ctrl + Alt + L locks the system.

注意:这里Linux的很多答案是Ctrl + Alt + L,这是错误的。在Linux中,按Ctrl + Alt + L锁定系统。

#17


1  

It's Ctrl + Alt + L for Windows. For a complete list of keyboard shortcuts please take a look at the user manual: https://developer.android.com/studio/intro/keyboard-shortcuts.html

它是Ctrl + Alt + L表示Windows。要获得完整的键盘快捷键列表,请参阅用户手册:https://developer.android.com/studio/intro/keyboard-shortcuts.html

#18


-1  

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导入无用的导入。

#19


-1  

You can use the following shortcut for code formatting: Ctrl+Alt+L

可以使用以下快捷方式进行代码格式化:Ctrl+Alt+L