gpt4 book ai didi

Android studio Kotlin 将函数调用参数放在同一行

转载 作者:行者123 更新时间:2023-12-02 12:50:54 26 4
gpt4 key购买 nike

Android Studio 以这种方式自动格式化方法调用:

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 Kotlin Code Style Settings

如果您取消选中它,那么您将允许 Android Studio 在可能的情况下删除换行符。这可能会产生意想不到的副作用,因为 Studio 会删除您没有预料到的地方的换行符。

关于Android studio Kotlin 将函数调用参数放在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61937141/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com