Xamarin 是如何获得本机外观的? [英] Xamarin how it is getting the Native Look and Feel?

查看:24
本文介绍了Xamarin 是如何获得本机外观的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Xamarin 的新手.我在这里没有什么困惑.

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

问题:

  1. Xamarin 如何获得 UI 组件的原生外观?
  2. Xamarin 是否提供自己的小部件 [如按钮、布局、..].

这是我的理解,如果我错了,请纠正我?

1) 通过原生 SDK 开发 UI [button, layout...].例如 iOS 使用 Xcode.安卓版?.

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

2) 考虑按钮,当按钮被按下时,将要执行的代码在整个平台上都很常见.

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

3) 因此,由于 UI 直接来自各自的 SDK,我们获得了原生外观.

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

请纠正我误解的地方?

推荐答案

我觉得你已经离题了.

Xamarin 在 iOS 和 Android 上提供 C# 和 .Net (Mono) 运行时.同时,他们将每个平台上的本机 API 公开给 C#.所以他们构建了一种让 C# 调用 Objective-C 和 Java(反之亦然)的方法.

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).

这意味着您可以在每个平台上开发原生 UI,并且可以在平台之间共享后端业务逻辑.Xamarin 应用程序可以跨平台共享 50-75% 的代码.没有跨平台的 UI 通用共享,因为这会抽象出原生 API.

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.

分解:

安卓

  • 使用 Xamarin Studio 或 Visual Studio 开发 C# 后端代码
  • 使用 Xamarin 的 Android 设计器来布局原生 Android XML 布局

iOS

  • 使用 Xamarin Studio 或 Visual Studio* 开发 C# 后端代码
  • 在 Mac 上使用 XCode 为原生 iOS UI 布局布局故事板或 XIB 文件

这两个选项您也都可以通过代码创建 UI,但每个平台上的原生 API 会有所不同.

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

*iOS 需要 mac 编译

*A mac is needed to compile for iOS

这篇关于Xamarin 是如何获得本机外观的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆