Is it possible to import an XML file with an interest in replacing XAML?

Asked

Viewed 155 times

0

Good morning ladies and gentlemen,

It would be possible to work with XML file (layout) made in Android Studio to use in visual studio in the case of android development with Xamarin. I would like to replace the AXML file that comes as standard in visual studio with the XML file that is generated by Android Studio.

PS: It sounds crazy but there is a google project that the developer only pastes the XML code or writes and sees everything being done next door by a smartphone without the need to use emulators, light and very practical.

http://labs.udacity.com/android-visualizer/#/android/linear-layout-Weight

1 answer

0


Do not confuse XAML with AXML. AXML is a name given to Android Studio layout XML files in Visual Studio. An AXML file has XML inside it. A XAML file is a layout file as well, but used in Xamarin Forms and other Microsoft applications such as WPF.

If you are working with Xamarin.Android, ie, a native project on Android through Xamarin, then yes, it is possible, because the layout of Android in Visual Studio is set through files called AXML that are nothing more than XML files.

If you are using Xamarin Forms, then no, it is not possible, because as previously said, Xamarin Forms uses XAML to define the layouts.

XAML and AXML are completely different layout files and are interpreted differently by the compiler.

In conclusion, you can quietly copy an XML layout from Android Studio and paste it into the Visual Studio’s Android AXML layout. Just note if it has any @string, @dimen, @style or @color property that refers to some other XML file created within the 'values' folder for example.

  • So if for example I want to develop for Android and Windows Phone using Xamarin (Visual studio) I would have to create a layout for android and WP ?

  • If you want to do this using code reuse, you will use Xamarin Forms, where you create the XAML layout only once and it creates the native layout on the other platforms automatically for you. Now if you want to do this individually, using Xamarin’s native programming, you will have to create layouts individually for each platform, be it Android, iOS or UWP.

  • @user3671786 if your question has been answered, please mark as reply, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.