1

我已经将我的 Android Studio 更新到了 3.3 版本,之后当我从托盘中拖动一些新视图时,它的 XML 非常奇怪,android:blabla在同一行中有错误的空格和两三个属性。当我制作热键命令 + shift + L 时,它会将所有具有错误空格的样式的代码。如何解决?

  <Button
      android:id="@+id/buttonLiteVersion"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:onClick="onLiteVersion"
      android:text="@string/lite_version_name"
      style="@style/MainMenuButton"
      android:layout_weight="1"/>
  <Button
          android:text="Button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:id="@+id/button2" android:layout_weight="1"/>

上为更新前,下为更新后

我的编辑器设置

4

1 回答 1

1

如果 command + shift + L(在 pc 上它的 Ctrl+Alt+L - 重新格式化代码)对您不起作用,请尝试更改您的设置:

 Settings->Editor->Code Style->XML->Android->Layout Files->Wrap Attributes
于 2019-04-04T11:43:40.770 回答