由於您使用GNU/Emacs進行Android開發的一些人,您一定知道最新的Android工具引入了new xml formatter。我用的是優秀nxml模式編輯XML,因爲......我編輯XML文件)和我很高興,但...我可以自定義Nxml屬性縮進變量,該文件說:自定義GNU/Emacs nxml模式縮進
Indentation for the attributes of an element relative to the start-tag. Hide
This only applies when the first attribute of a tag starts a line.
In other cases, the first attribute on one line is indented the same
as the first attribute on the previous line.
什麼重要的是當獨立屬性與第一個屬性相同時,該屬性與該元素位於同一行上的回退。
這是可能改變這種行爲,以獲得Android工具兼容縮進?我只是沒有發現任何的文檔和谷歌搜索失敗...
更新:
註釋幫助我意識到,我並不清楚。因此,這裏是一個什麼nxml模式的默認操作爲例:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.foo.bar"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<activity
android:name="Foo"
android:label="@string/foo" />
<activity android:name="Bar"
android:label="@string/bar" />
</application>
</manifest>
我希望得到什麼:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.foo.bar"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<activity
android:name="Foo"
android:label="@string/foo" />
<activity android:name="Bar"
android:label="@string/bar" />
</application>
</manifest>
第一種情況(默認nxml模式壓痕行爲):
- 的
manifest
元件的package
屬性與xmlns:android decl
- 的對準元素的屬性
Bar activity
元素與android:name
元素對齊。
第二種情況(預期的結果):
- 的
manifest
元件的package
屬性與父manifest
元件加的空間可配置數量的對準 - 的
Bar activity
元件的android:label
屬性是與父元素對齊,加上可配置的空格數
I ha我瀏覽了nxml模式的源代碼,並且縮進行爲以nxml-indent-line
開頭,但由於我缺少lisp知識,我未能遵循許多subcalls來查看應該自定義什麼defun
...。
你可以看到manifest
秒屬性不與第一
乾杯對齊,
雷諾(很難管理大量的頭痛與Android編碼和格式規則,以符合)
你能展示一些XML例子嗎?我不明白你的意思是「當第一個屬性與元素位於同一行時,獨立屬性與第一個屬性對齊的回退」。 – mzjn 2011-12-14 11:24:10
使用XML片段更新的問題;)對不起,我應該先把它們放在... – Renaud 2011-12-14 12:28:20