You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio更新后自动格式化代码不保留换行的问题求助

Android Studio 代码自动格式化调整方案

链式调用格式调整步骤:

  1. 打开Android Studio设置:

    • Windows/Linux:File → Settings
    • Mac:Android Studio → Settings
  2. 进入代码样式配置:
    依次展开 Editor → Code Style,根据代码语言选择Java或Kotlin。

  3. 调整链式调用规则:
    切换到Wrapping and Braces选项卡,找到Chained method calls区域:

    • 选择Wrap always(强制每个链式方法单独换行)
    • 在Indent下拉菜单中选择Indent by,设置与示例匹配的缩进值(比如8个空格,或项目统一的缩进单位)
  4. 验证效果:
    选中目标代码,按下格式化快捷键(Windows/Linux:Ctrl+Alt+L;Mac:Cmd+Option+L),即可得到如下格式:

openCameraObservable
            .debounce(200, TimeUnit.MILLISECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({}, {})

内容的提问来源于stack exchange,提问作者Kingfisher Phuoc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 12:45:26