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

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.

主站蜘蛛池模板: 札达县| 桓台县| 剑川县| 常熟市| 华坪县| 乡宁县| 巩义市| 红河县| 临潭县| 清涧县| 兴安县| 西乡县| 麻栗坡县| 丹凤县| 麦盖提县| 房山区| 昭觉县| 平远县| 顺昌县| 都安| 普宁市| 鄂伦春自治旗| 华宁县| 木里| 建始县| 宜宾市| 海兴县| 百色市| 灵川县| 闸北区| 安远县| 神池县| 开封县| 繁峙县| 那曲县| 宣化县| 惠来县| 冀州市| 天水市| 江华| 海盐县|