How To Add ScrollView In Xamarin.Forms Application For Android And UWP

ScrollView contains layouts and enables them to scroll offscreen. ScrollView is also used to allow the views to automatically move to the visible portion of the screen when the keyboard is showing.

Before reading this article, please go through the article How To Create And Use XAML Content Page In Xamarin.Forms Application For Android And Universal Windows Platform

Reading this article, you will learn how to add ScrollView in Xamarin.Forms application for Android and Universal Windows Platform app development.

The following important tools are required for developing UWP.

  1. Windows 10 (Recommended).
  2. Visual Studio 2015 Community Edition (It is a free software available online).
  3. Using Visual Studio 2015 Installer, enable Xamarin and C#/.NET when you install/modify Visual Studio 2015.

Now, we can discuss step by step app development.

Step 1

Open Visual Studio 2015. Go to Start -> New Project-> select Cross-Platform (under Visual C# -> Blank App (Xamarin.Forms Portable) -> Give a suitable name for your app (XamFormScroll) -> OK.

Visual studio

Now, create project “XamFormScroll_Droid”.

Step 2
 
Choose the target and minimum platform versions for your Universal Windows Project. 

Visual studio

Create project “XamFormScroll _UWP”.

Visual studio

Step 3

Afterwards, Visual Studio creates 6 projects and displays GettingStarted.Xamarin Page. Now, we have to update the Xamarin. Forms Reference for portable project and XamFormScroll _Droid project.

(Please refer to  How To Create And Use XAML Content Page In Xamarin Forms Application For Android And Universal Windows Platform).

Step 4

Add XAML page for ScrollView demo. Right click XamFormScroll (Portable) project, select Add >> NewItem and select CrossPlatform-> FormXamlPage -> Give a relevant name.

Visual studio

Step 5

Add ScrollView tag, 2 Labels and 20 Entry Controls in ScrollViewDemo.xaml.
  1. <ScrollView>  
  2.     <StackLayout>  
  3.         <Label x:Name="lblTitle" Text="Scroll Viewer in Xamarin Forms - UWP and Android Demo" Font="Large" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />  
  4.         <Label x:Name="lblDetails" Text="Personal Details" Font="Large" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />  
  5.         <Entry Placeholder="Enter Your Name " />  
  6.         <Entry Placeholder="Enter Your Email ID " />  
  7.         <Entry Placeholder="Enter Your Phone Number " />  
  8.         <Entry Placeholder="Enter Your Address Door No " />  
  9.         <Entry Placeholder="Enter Your Address Street Name " />  
  10.         <Entry Placeholder="Enter Your Address Locality " />  
  11.         <Entry Placeholder="Enter Your Address Taluk " />  
  12.         <Entry Placeholder="Enter Your Address City " />  
  13.         <Entry Placeholder="Enter Your Address State " />  
  14.         <Entry Placeholder="Enter Your Address Country " />  
  15.         <Entry Placeholder="Enter Your Qualification -Highest Degree " />  
  16.         <Entry Placeholder="Enter Your Qualification -PG Degree " />  
  17.         <Entry Placeholder="Enter Your Qualification -PG Degree Percentage " />  
  18.         <Entry Placeholder="Enter Your Qualification -UG Degree " />  
  19.         <Entry Placeholder="Enter Your Qualification -UG Degree Percentage " />  
  20.         <Entry Placeholder="Enter Your Qualification -10th Percentage " />  
  21.         <Entry Placeholder="Enter Your BloodGroup " />  
  22.         <Entry Placeholder="Enter Your Father Name " />  
  23.         <Entry Placeholder="Enter Your Mother Tongue " />  
  24.         <Entry Placeholder="Enter Your Technical Skills " />  
  25.     </StackLayout>  
  26. </ScrollView>// This is just a sample script. Paste your real code (javascript or HTML) here. if ('this_is'==/an_example/){of_beautifier();}else{var a=b?(c%d):e[f];}  
Visual studio

Step 6

Open (double click) the file App.cs in the Solution Explorer-> XamFormScroll (portable) and set the Root page.

Visual studio

Step 7

We will test Android and UWP. Thus, we can set the multiple startup projects as XamFormScroll.Droid and XamFormScroll.UWP (Universal Windows).

Visual studio

Step 8

Change the Configuration Manager settings. Go to Build -> Configuration Manager, uncheck all the "Build" and "Deploy" options except for Droid and UWP.

Visual studio

Step 9

Deploy your app in Local Machine. The output of the XamFormScroll App is given below.

Visual studio

Summary

Now, you have successfully created and tested ScrollView in Xamarin.Forms Application, using Visual C# and Xamarin.


Similar Articles