Android的工作室code格式问题 [英] Android Studio code formatting issue
问题描述
我使用的Android Studio和格式化code时,有一个问题。当存在拆分成多行的声明,我需要格式化单个行语句,我不能使用(按Ctrl + Alt + L)做到这一点。在code没有格式化为使用快捷键一行。
I am using Android Studio and having an issue when formatting the code. When there is a statement that breaks into multiple lines and I need to format that to a single line statement, I can't do it using (Ctrl+Alt+L). The code didn't format to a single line using that shortcut.
我试过的右页边距的值更改(设置 - >编辑 - > code款)到一个更高的数字,但也没有工作。
I tried changing the value of Right margin(Settings -> Editor -> Code Style) to a higher number, but that also didn't work.
如何到code格式以一行?
How to format the code to a single line?
感谢。
推荐答案
首先去 preferences>编辑> code风格
并设置右页边距(列)
到 140
(或更高版本)
First go to Preferences > Editor > Code Style
and set Right margin (columns)
to 140
(or higher)
现在转到 preferences>编辑> code样式和GT; Java的>包装和大括号>请重新格式化
和取消选中
复选框换行
,所以格式化将删除不必要线的时候场所及使语句适合尽可能在一个单一的行
Now go to Preferences > Editor > Code Style > Java > Wrapping and Braces > Keep when reformatting
and uncheck
the checkbox Line Breaks
, so the formatter will remove unnecessary line breaks and make the statement fit as much as possible in one single line
还建议,在 preferences>编辑> code样式和GT; Java的>包装和大括号
务必检查
复选框确保右边距不超过
使当声明超过最大右边距格式化将强制断线。
Also recommended, in Preferences > Editor > Code Style > Java > Wrapping and Braces
make sure to check
the checkbox Ensure right margin is not exceeded
so that the formatter will force a line break when the statement exceeds the maximum right margin.
这篇关于Android的工作室code格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!