简体   繁体   中英

XML Decleration necessary in Android XML Files (e.g. Layouts)?

I am working on my first Android app (just did iOS and WP before) and wonder if the XML Decleration in the different XML files is important or not.

When creating a new XML file in Eclipse the XML Decleration is automatically included ( = well formed XML ) but I found many sources (eg third party controls, tutorials, etc.) that do not use a XML Decleration in their XML files, eg.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout ... >
   ...
</RelativeLayout>

vs.

<RelativeLayout ... >
   ...
</RelativeLayout>

I know, that in general the XML Decleration is optional , but is this also true for Android in particular?

So far I could not observe any problems, warings, etc. when using XML files without XML Decleration in Android. I assume that as long as the debugger and the compiler do not have problems with these files there will be no problems on the devices as well. But since I am not a 100% sure and since I came across some very strange problems using non-well formed XMLs in other SDKs I would like to double check:

Could using XML files without `XML Decleration have any negative impact on my Android project?

(of cource I could check every XML file in my project and just add a XML Decleration if it is missing. however I would like to know/understand if this is really necessary or just perfectionism)

This may important but if you use in your xml files you can prevent from some issues. This is very important while creating high level application development. It is very good habit to use as a developer and also looks very standard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM