Android studio Kotlin将函数调用参数放在同一行上
Android Studio通过以下方式自动格式化方法调用:Android studio Kotlin将函数调用参数放在同一行上,android,android-studio,kotlin,Android,Android Studio,Kotlin,Android Studio通过以下方式自动格式化方法调用: HelperFunctions.showProperty( layoutInflater, propertyInsertPoint, getString(R.string.height), resident.height.toString() ) HelperFunctions.showProperty(layoutInflater, propertyInsertPoint, getStrin
HelperFunctions.showProperty(
layoutInflater,
propertyInsertPoint,
getString(R.string.height),
resident.height.toString()
)
HelperFunctions.showProperty(layoutInflater, propertyInsertPoint, getString(R.string.height), resident.height.toString())
我希望它能以这种方式自动格式化它们:
HelperFunctions.showProperty(
layoutInflater,
propertyInsertPoint,
getString(R.string.height),
resident.height.toString()
)
HelperFunctions.showProperty(layoutInflater, propertyInsertPoint, getString(R.string.height), resident.height.toString())
如何实现这一点?Android Studio使用您的行长设置(从设置>编辑器>代码样式、
.editorconfig
等)来决定重新格式化时是否需要添加换行符。但是,默认情况下,即使您增加了“行长度”设置,Android Studio也不会删除换行符,即使之前已经添加了换行符
这是由特定语言的代码样式中的“重新格式化时保留>换行符”控制的,例如Kotlin:
如果您取消选中该选项,那么您将允许Android Studio在可能的情况下删除换行符。这可能会产生意想不到的副作用,Studio会在您没有预料到的地方删除换行符。尝试设置更长的行长(设置>编辑器>代码样式)。@Commonware我尝试过,但没有效果。如果我按ctrl+alt+L,代码保持不变,默认情况下不会删除空行;较长的行长度首先是为了防止Studio包装函数声明。如果希望Studio删除空行。。。尝试“设置”>“编辑器”>“代码样式”>“Kotlin”>“包装和大括号”>“重新格式化时保留”。@Commonware运行正常,谢谢