官术网_书友最值得收藏!

Xamarin on Android – Mono Droid

Following the same methodology, we can recreate the Xamarin.Forms view we created using Xamarin.Android using a native project template. In order to do this, we can reuse the existing Xamarin classic project that we used for iOS and add an Android application project instead:

This will create a standard boilerplate application project for Xamarin.Android with a single view and associated layout file. If you open the created Main.axml file, the designer view will be loaded, which can be used to create our welcome view:

When handling the Android XML layout files, developers are given the option to either use the designer or the source view. By using the designer view to create the welcome view, you would have to drag and drop the text view control and adjust the alignment, layout, and gravity properties for the label.

Using the source view, you can also paste the following layout declaration to see what the application looks like when run on the Android platform:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textView1"
android:text="Welcome to Xamarin!"
android:gravity="center_vertical"
android:textAlignment="center" />
</LinearLayout>

When we finally compile and run our first Xamarin.Android application, you will see the welcome view that was created on Xamarin.Forms and Xamarin.iOS.

The Xamarin.Android platform functions a little more like .NET Core. Unlike Xamarin.iOS, there are no restrictions on code generation, so the Mono Droid runtime execution is done using the JIT compiler, which is responsible for providing the IL packages that are part of the application package. The Mono Droid runtime exists in the application package in the form of native code that replaces the .NET Core runtime:

For Xamarin.Forms applications, the same compilation and runtime procedures, such as AOT and JIT, apply, depending on the targeted platform.

主站蜘蛛池模板: 昌图县| 宜兴市| 阿坝县| 连南| 慈溪市| 清涧县| 大同市| 开封县| 衡阳县| 息烽县| 深水埗区| 阆中市| 浑源县| 通城县| 桓台县| 获嘉县| 团风县| 胶南市| 虎林市| 彰武县| 武川县| 延庆县| 新绛县| 陇川县| 射洪县| 浦东新区| SHOW| 威海市| 平和县| 锡林浩特市| 彝良县| 罗源县| 柳河县| 中江县| 呼玛县| 丽江市| 滨海县| 裕民县| 临湘市| 洛浦县| 如皋市|