我有一个用旧版本的 Eclipse 制作的项目。它充满了空的正文标签,例如
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"></EditText>
我想将其转换为空结束标记,这是我喜欢的方式。想要得到这样的结束标签
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Android Studio 突出显示空的正文标记项,它可以自动将其转换为空的结束标记(Alt+Enter
-> Replace Tag Empty Body With Empty End),但我必须通过以下方式进行操作:一。
我尝试突出显示所有此类小部件并按 Alt+Enter
,它显示了相同的命令,但按下它只会更改选择中的第一个小部件。我预计所有突出显示的元素都会发生变化。
如何将所有带有空 body 标签的小部件批量转换为空结尾?
最佳答案
还有另一个菜单,默认情况下不可见。按 Alt+Enter
后,导航至将标签空正文替换为空结尾
,然后按键盘上的右箭头键显示子菜单,然后选择“修复所有 XML 标记空正文问题”。
太糟糕了,这个菜单很难被注意到,因为我花了很多时间手动解决这些问题。
关于android-layout - 如何用空结束标记 (/>) 批量替换空正文标记 (</TextView>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27875139/