Xamarin how it is getting the Native Look and Feel

2020-05-27 04:39发布

问题:

I am new to Xamarin. I have few confusion here.

Question:

  1. How does Xamarin get the Native Look and Feel of the UI Components?.
  2. Does Xamarin Provide their own Widgets [ like button, Layouts, ..].

Here is my understanding Correct me if I am wrong?.

1) Develop the UI [ button, layout...] by native SDK. For example iOS use Xcode. for Android ?.

2) Consider the button, when the button is pressed, the the code which is going to get executed is common across the platform.

3) So, Since UI are directly from their respective SDK, we get the Native Look and Feel.

Kindly correct me where I misunderstood?.

回答1:

I think you are way off.

Xamarin provides C# and the .Net (Mono) runtime on iOS and Android. At the same time they expose the native APIs on each platform to C#. So they built a way for C# to call into Objective-C and Java (and vice versa).

This means you develop native UIs on each platform, and can share backend business logic between platforms. A Xamarin app can share somewhere between 50-75% of its code across platforms. There is no general sharing of the UI across platforms, since this would abstract away the native APIs.

To break it down:

Android

  • Use Xamarin Studio or Visual Studio to develop your C# backend code
  • Use Xamarin's Android designer to layout native Android XML layouts

iOS

  • Use Xamarin Studio or Visual Studio* to develop your C# backend code
  • Use XCode on a Mac to layout storyboard or XIB files for native iOS UI layout

Both options you can create your UI from code as well, but the native APIs will be different on each platform.

*A mac is needed to compile for iOS