Android Studio如何格式化XML代码顺序。

来源:互联网 发布:c语言获取当前日期时间 编辑:程序博客网 时间:2024/05/17 04:03

之前用Eclipse时,格式化XML代码,也会把顺序格式化,这样比较方便,看起来也清晰明了。

比如:

<pre name="code" class="html"><TextView style="@style/personal_tv"         android:id="@+id/personal_reply_1st_title"         android:text="你真好用英语怎么表达"/>

用Eclipse格式化时,会变成:

<TextView         android:id="@+id/personal_reply_1st_title"         style="@style/personal_tv"         android:text="你真好用英语怎么表达" />
Android Studio解决办法:

  1. File > Settings > Code Style > XML > Set from > Predefined Style > Android
  2. 勾上File > Settings > Editor > Formatting > Show "Reformat Code" 选项
  3. 在XML处格式化代码(默认快捷键是CTRL+ALT+L ,Eclipse是:CTRL+ALT+F)
  4. 在弹出 的对话框中勾Rearrange entries 选项
解决办法出自:StackOverFlow

0 0
原创粉丝点击