Xamarin: Frame Layout
Introduction
Xamarin is a platform to develop cross-platform and multi-platform apps (for example, Windows phone, Android, iOS).
In the Xamarin platform, the code sharing concept is used. In Xamarin Studio, Visual Studio is also available.
Format Of Frame Layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
Design
Go to the solution explorer. in the solution explorer is have the all files and source in your project. Next Select Resource-->Layout-->double click to open main.xaml page. you want select source to write the xaml code. you want design choose the designer window you can design your app.
Main.xaml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/monkey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:scaleType="centerCrop" />
<TextView
android:text="Absolute Layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:padding="16dp"
android:background="#f8852e02"
android:id="@+id/textView1" />
</FrameLayout>
Operation
go to MainActivity.cs page. Write the code, mentioned below between OnCreate() Method
MainActivity.cs
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
Run
If you have Android Virtual device, run the app on it. Else, connect your Android phone and run the app in that.
Simply, connect your phone and go to Visual Studio. The connected phone will show up in the Run menu (Ex:My Android Phone). Click the Run option.
Output
After a few seconds, the app will start running on your phone. You will see the Frame Layout is work Successfully.