简体   繁体   English

Android工作室Kotlin把function调用参数放在同一行

[英]Android studio Kotlin put function call parameters on the same line

Android Studio automatically formats method calls this way: Android Studio 以这种方式自动格式化方法调用:

HelperFunctions.showProperty(
    layoutInflater,
    propertyInsertPoint,
    getString(R.string.height),
    resident.height.toString()
)

I would like it to automatically format them this way:我希望它以这种方式自动格式化它们:

    HelperFunctions.showProperty(layoutInflater, propertyInsertPoint, getString(R.string.height), resident.height.toString())

How can I achieve this?我怎样才能做到这一点?

Android Studio uses your line length settings — from Settings > Editor > Code Style, .editorconfig , etc. — to decide if it needs to add line breaks when reformatting. Android Studio 使用您的行长设置(从 Settings > Editor > Code Style、 .editorconfig等)来决定在重新格式化时是否需要添加换行符。 However, by default, even if you increase the line length setting, Android Studio will not remove line breaks, even if it had added them previously.但是,默认情况下,即使您增加行长设置,Android Studio 也不会删除换行符,即使它之前添加了换行符。

That is controlled by "Keep when reformatting > Line breaks" in the code style for your particular language, such as Kotlin:这由特定语言的代码样式中的“重新格式化时保持 > 换行符”控制,例如 Kotlin:

Android Studio Kotlin 代码样式设置

If you uncheck that, then you are allowing Android Studio to remove line breaks where possible.如果您取消选中它,那么您将允许 Android Studio 尽可能删除换行符。 That may have unintended side effects, with Studio removing line breaks in places that you had not anticipated.这可能会产生意想不到的副作用,因为 Studio 会在您没有预料到的地方删除换行符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM