I am trying to export the Visual Studio layout to XML and then import it into Android Studio, but I have a problem.
The code at the moment generates the first line of the XML that Android Studio has.
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" />
But when exporting in XML the "android:" disappear leaving only
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" layout_width = "match_parent" layout_height = "match_parent" />
What can be done so that it doesn't ignore the "android:"?
To do the XML I use the following;
using System.Xml;
using System.Xml.Serialization;
...
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode;
string filename = "export.xml";
if (System.IO.File.Exists(filename))
{
xmlDoc.Load(filename);
rootNode = xmlDoc.SelectSingleNode("LinearLayout");
}
else
{
rootNode = xmlDoc.CreateElement("LinearLayout");
xmlDoc.AppendChild(rootNode);
XmlAttribute link = xmlDoc.CreateAttribute("xmlns:android");
link.Value = "http://schemas.android.com/apk/res/android";
rootNode.Attributes.Append(link);
XmlAttribute widthRoot = xmlDoc.CreateAttribute("android:layout_width");
widthRoot.Value = "match_parent";
rootNode.Attributes.Append(widthRoot);
XmlAttribute heightRoot = xmlDoc.CreateAttribute("android:layout_height");
heightRoot.Value = "match_parent";
rootNode.Attributes.Append(heightRoot);
}
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = new UTF8Encoding(false); // Falso = no escribir BOM
settings.Indent = true;
XmlWriter writer = XmlTextWriter.Create(filename, settings);
xmlDoc.Save(writer);
question from:
https://stackoverflow.com/questions/65860990/export-a-layout-from-visual-studio-to-android-studio-with-xml 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…