When are closing tags required with Android view markup?

戏子无情 提交于 2019-12-01 17:44:57

The <Button /> is a so called short tag. This is safe.

If a tag has no body you can obmit the closing tag and add a slash at the end of the tag which means here this tag has no children.

This notation is very common in xhtml for <br /> and <img src="" alt="" /> tags.

The benifit is that you don't need to write the closing tag which makes it simpler to read and if you have a huge xml file there are less data to transport. (This does not count for Android is this case, because the android SDK procudes internally a binary file.)

If no other element like this for example <something></something> is inside another element then the end tag /> can be used. So in your example the EditText can end also with the /> tag.

When you want to add another element to your EditText then you need to close the XML of EditText with .

Vatsal Shah

for '>' write in XML

please write as mention below

android:text="Subtract &gt; 1"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!