Saturday, 4 November 2017

Xamarin Forms Local Email Validation [Tutorial 28]


Step1:
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<Entry x:Name="EntryEmail" Placeholder="Enter Email"/>
<Label x:Name="LabelError" TextColor="Red"/>
<Button Text="Lets Validate" Clicked="Validar"
BackgroundColor="SeaGreen" TextColor="Wheat"/>
</StackLayout>
view raw Something.xaml hosted with ❤ by GitHub
Step2:
public void Validar(Object sender, EventArgs e)
{
var email = EntryEmail.Text;
var emailPattern = "^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$";
if (!String.IsNullOrWhiteSpace(email) && !(Regex.IsMatch(email, emailPattern)))
{
LabelError.Text = "EmailVerification Failed";
}
else
{
LabelError.Text = "";
}
}
view raw Something.cs hosted with ❤ by GitHub
Step3: Holaa!! Tutorial Completes...

Xamarin Forms Label Clicked Event [Tutorial 43]


Step1:Page1.cs
public partial class Page1 : ContentPage
{
Label labelSuggestion;
public Page1()
{
InitializeComponent();
labelSuggestion = new Label()
{
Text = "Please Click US",
IsVisible = true,
TextColor = Color.Black,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
BackgroundColor = Color.Green,
};
Content = labelSuggestion;
this.Content = new StackLayout
{
Children =
{
labelSuggestion
}
};
labelSuggestion.GestureRecognizers.Add(new TapGestureRecognizer((view) => OnLabelClicked()));
}
//private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
// {
// await Navigation.PushAsync(new Page2());
// }
private async void OnLabelClicked()
{
//var url = "https://docs.google.com/forms/d/e/1FAIpQLSdGn31o21N1s8ixMPqfSmtk07SHiL-FJCCm10kK6enrsZwpbw/viewform";
//Device.OpenUri(new Uri(url));
await Navigation.PushAsync(new Page2());
}
}
}
view raw page1.cs hosted with ❤ by GitHub
Step2:
<!--<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Label Text="This is Label Clicked Event"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer
Tapped="TapGestureRecognizer_Tapped"
/>
</Label.GestureRecognizers>
</Label>
</StackLayout>-->
view raw page1.xaml hosted with ❤ by GitHub
Step3: Holaaa!!! Tutorial Completes

Xamarin Forms Button Clicked Event [Tutorial 40]


Step1: Page1.xaml
<ContentPage.Content>
<!--<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Button Text="When I Am Clicked" HorizontalOptions="Center" VerticalOptions="Center"
Clicked="Button_Clicked"/>
</StackLayout>-->
</ContentPage.Content>
view raw page1.xaml hosted with ❤ by GitHub
Page1.cs
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
var button = new Button { Text = "Hello World",
BackgroundColor = Color.Black,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
TextColor = Color.White };
button.Clicked += ButtoncbClicked;
Content = button;
this.Content = new StackLayout
{
Children =
{
button
}
};
}
private async void ButtoncbClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new Page2());
}
//private async void buttoncbclicked(object sender, eventargs e)
//{
// await navigation.pushasync(new page2());
//}
// This is for Our Xaml Part Button Clicked
//private async void Button_Clicked(object sender, EventArgs e)
//{
// await Navigation.PushAsync(new Page2());
//}
}
}
//private void ButtoncbClicked(object sender, EventArgs e)
//{
// await Navigation.PushAsync(new Page2());
//}
//private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
//{
//}
view raw page1.cs hosted with ❤ by GitHub
Step2: Holaa!!!! No More Steps

Xamarin Forms Image Cell [Tutorial 42]


Step1: Create Anything.xaml
<TableView Intent="Form">
<TableRoot>
<TableSection Title="Sports for Fitness">
<ImageCell ImageSource="CricketLogo.jpg" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="fooftball.jpg" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="gymlogo.png" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="Hockey.gif" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="volleybal.png" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="volleybal.png" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
<ImageCell ImageSource="Hockey.gif" Text="Tpoe" Detail="It is a Best Part Of Body"></ImageCell>
</TableSection>
</TableRoot>
</TableView>
view raw Anything.Xaml hosted with ❤ by GitHub
Step2: Hola!! Your OutPut is Ready!!!

Xamarin Forms Image Clicked Event [Tutorial 41]

Step1: Create A Xaml File

<StackLayout>
<Image Source="unnamed.jpg" VerticalOptions="Center" HorizontalOptions="Center">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
view raw Something.xaml hosted with ❤ by GitHub
Step2: Create a Clicked Event

private async void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
await Navigation.PushAsync(new Page2());
}
view raw Something.cs hosted with ❤ by GitHub
Step3:Hola!!! No More Steps

Xamarin Forms Grid View [Tutorial 39]

Step1:
<Grid RowSpacing="5" ColumnSpacing="5" BackgroundColor="Black">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="unnamed.jpg" Grid.Row="0" Grid.Column="0" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
</Image>
<Image Source="unnamed.jpg" Grid.Row="0" Grid.Column="1" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
</Image>
<Image Source="unnamed.jpg" Grid.Row="1" Grid.Column="0" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
</Image>
<Image Source="unnamed.jpg" Grid.Row="1" Grid.Column="1" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
</Image>
</Grid>
view raw MainPage.xaml hosted with ❤ by GitHub
Step2:Hola!! your Solution IS Ready

Xamarin Forms Shadow Effect [Tutorial 38]

Step1:ShadowEffect.cs
public class ShadowEffect : RoutingEffect
{
public float Radius { get; set; }
public Color Color { get; set; }
public float DistanceX { get; set; }
public float DistanceY { get; set; }
public ShadowEffect () : base ("MyCompany.LabelShadowEffect")
{
}
}
view raw ShadowEffect.cs hosted with ❤ by GitHub
Step2:HomePage
<Grid Padding="0,20,0,0">
<Label Text="Introducing New Black BMW" FontAttributes="Bold"
HorizontalOptions="CenterAndExpand" VerticalOptions="StartAndExpand" FontSize="Large">
<Label.Effects>
<local:ShadowEffect Radius="5" DistanceX="5" DistanceY="5">
<local:ShadowEffect.Color>
<OnPlatform x:TypeArguments="Color">
<On Platform="iOS" Value="Black" />
<On Platform="Android" Value="White" />
<On Platform="UWP" Value="Red" />
</OnPlatform>
</local:ShadowEffect.Color>
</local:ShadowEffect>
</Label.Effects>
</Label>
</Grid>
view raw HomePage.xaml hosted with ❤ by GitHub
Step3:Android Renderer
[assembly:ResolutionGroupName ("MyCompany")]
[assembly:ExportEffect (typeof(LabelShadowEffect), "LabelShadowEffect")]
namespace EffectsDemo.Droid
{
public class LabelShadowEffect : PlatformEffect
{
protected override void OnAttached ()
{
try {
var control = Control as Android.Widget.TextView;
var effect = (ShadowEffect)Element.Effects.FirstOrDefault (e => e is ShadowEffect);
if (effect != null) {
float radius = effect.Radius;
float distanceX = effect.DistanceX;
float distanceY = effect.DistanceY;
Android.Graphics.Color color = effect.Color.ToAndroid ();
control.SetShadowLayer (radius, distanceX, distanceY, color);
}
} catch (Exception ex) {
Console.WriteLine ("Cannot set property on attached control. Error: ", ex.Message);
}
}
protected override void OnDetached ()
{
}
}
}
Step4:IOS Renderer
[assembly:ResolutionGroupName ("MyCompany")]
[assembly:ExportEffect (typeof(LabelShadowEffect), "LabelShadowEffect")]
namespace EffectsDemo.iOS
{
public class LabelShadowEffect : PlatformEffect
{
protected override void OnAttached ()
{
try {
var effect = (ShadowEffect)Element.Effects.FirstOrDefault (e => e is ShadowEffect);
if (effect != null) {
Control.Layer.CornerRadius = effect.Radius;
Control.Layer.ShadowColor = effect.Color.ToCGColor ();
Control.Layer.ShadowOffset = new CGSize (effect.DistanceX, effect.DistanceY);
Control.Layer.ShadowOpacity = 1.0f;
}
} catch (Exception ex) {
Console.WriteLine ("Cannot set property on attached control. Error: ", ex.Message);
}
}
protected override void OnDetached ()
{
}
}
}
Step5:Holaa!!! No More Steps

Xamarin Forms Image Zoom[Tutorial 37]

Step1:DoubleExtensions.cs
public static class DoubleExtensions
{
public static double Clamp (this double self, double min, double max)
{
return Math.Min (max, Math.Max (self, min));
}
}
Step2:Create a Container.cs
public class PinchToZoomContainer : ContentView
{
double currentScale = 1;
double startScale = 1;
double xOffset = 0;
double yOffset = 0;
public PinchToZoomContainer ()
{
var pinchGesture = new PinchGestureRecognizer ();
pinchGesture.PinchUpdated += OnPinchUpdated;
GestureRecognizers.Add (pinchGesture);
}
void OnPinchUpdated (object sender, PinchGestureUpdatedEventArgs e)
{
if (e.Status == GestureStatus.Started) {
// Store the current scale factor applied to the wrapped user interface element,
// and zero the components for the center point of the translate transform.
startScale = Content.Scale;
Content.AnchorX = 0;
Content.AnchorY = 0;
}
if (e.Status == GestureStatus.Running) {
// Calculate the scale factor to be applied.
currentScale += (e.Scale - 1) * startScale;
currentScale = Math.Max (1, currentScale);
// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the X pixel coordinate.
double renderedX = Content.X + xOffset;
double deltaX = renderedX / Width;
double deltaWidth = Width / (Content.Width * startScale);
double originX = (e.ScaleOrigin.X - deltaX) * deltaWidth;
// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the Y pixel coordinate.
double renderedY = Content.Y + yOffset;
double deltaY = renderedY / Height;
double deltaHeight = Height / (Content.Height * startScale);
double originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;
// Calculate the transformed element pixel coordinates.
double targetX = xOffset - (originX * Content.Width) * (currentScale - startScale);
double targetY = yOffset - (originY * Content.Height) * (currentScale - startScale);
// Apply translation based on the change in origin.
Content.TranslationX = targetX.Clamp (-Content.Width * (currentScale - 1), 0);
Content.TranslationY = targetY.Clamp (-Content.Height * (currentScale - 1), 0);
// Apply scale factor
Content.Scale = currentScale;
}
if (e.Status == GestureStatus.Completed) {
// Store the translation delta's of the wrapped user interface element.
xOffset = Content.TranslationX;
yOffset = Content.TranslationY;
}
}
}
Step3:Homepagexaml
<Grid Padding="20">
<local:PinchToZoomContainer>
<local:PinchToZoomContainer.Content>
<Image Source="Free.jpg" />
</local:PinchToZoomContainer.Content>
</local:PinchToZoomContainer>
</Grid>
view raw HomePage.xaml hosted with ❤ by GitHub
Step4:Holaaa!!! No More Steps

Xamarin Forms Pan Gesture [Tutorial 36]

Step1:HomePage.xaml
<AbsoluteLayout>
<local:PanContainer>
<Image Source="black.jpg" WidthRequest="1024" HeightRequest="768" />
</local:PanContainer>
</AbsoluteLayout>
view raw HomePage.xaml hosted with ❤ by GitHub
Step2:PanContainer.cs
double x, y;
public PanContainer ()
{
// Set PanGestureRecognizer.TouchPoints to control the
// number of touch points needed to pan
var panGesture = new PanGestureRecognizer ();
panGesture.PanUpdated += OnPanUpdated;
GestureRecognizers.Add (panGesture);
}
void OnPanUpdated (object sender, PanUpdatedEventArgs e)
{
switch (e.StatusType) {
case GestureStatus.Running:
// Translate and ensure we don't pan beyond the wrapped user interface element bounds.
Content.TranslationX = Math.Max (Math.Min (0, x + e.TotalX), -Math.Abs (Content.Width - App.ScreenWidth));
Content.TranslationY = Math.Max (Math.Min (0, y + e.TotalY), -Math.Abs (Content.Height - App.ScreenHeight));
break;
case GestureStatus.Completed:
// Store the translation applied during the pan
x = Content.TranslationX;
y = Content.TranslationY;
break;
}
}
}
}
view raw PanContainer.cs hosted with ❤ by GitHub
Step3:Hola!!!!No More Steps

Xamarin Forms Custom Fonts [Tutorial 35]

Step1:CustomNavigation.xaml

<NavigationPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CustomFontsNavigationPage.Views.CustomNavigationPage">
</NavigationPage>
Step2:CustomNavigation.xaml.cs

public CustomNavigationPage() : base()
{
InitializeComponent();
}
public CustomNavigationPage(Page root) : base(root)
{
InitializeComponent();
}
Step3:MainView.xaml

Title="Custom font Main Page">
view raw MainView.xaml hosted with ❤ by GitHub
Step4:AndroidRenderer

[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationPageRenderer))]
namespace CustomFontsNavigationPage.Droid.Renderers
{
public class CustomNavigationPageRenderer : NavigationPageRenderer
{
private Android.Support.V7.Widget.Toolbar _toolbar;
public override void OnViewAdded(Android.Views.View child)
{
base.OnViewAdded(child);
if (child.GetType() == typeof(Android.Support.V7.Widget.Toolbar))
{
_toolbar = (Android.Support.V7.Widget.Toolbar)child;
_toolbar.ChildViewAdded += Toolbar_ChildViewAdded;
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if(disposing)
{
_toolbar.ChildViewAdded -= Toolbar_ChildViewAdded;
}
}
private void Toolbar_ChildViewAdded(object sender, ChildViewAddedEventArgs e)
{
var view = e.Child.GetType();
if (e.Child.GetType() == typeof(Android.Widget.TextView))
{
var textView = (Android.Widget.TextView)e.Child;
var spaceFont = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, "segoesc.ttf");
textView.Typeface = spaceFont;
_toolbar.ChildViewAdded -= Toolbar_ChildViewAdded;
}
}
}
}
Step5:Ios Renderer

[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationPageRenderer))]
namespace CustomFontsNavigationPage.iOS.Renderers
{
public class CustomNavigationPageRenderer : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
var att = new UITextAttributes();
att.Font = UIFont.FromName("segoesc.ttf", 20);
UINavigationBar.Appearance.SetTitleTextAttributes(att);
}
}
}
}
Step6:Holaa!! No more Steps :D

Xamarin Forms Data Entry Intent[Tutorial 34]

Step1: Design Your MainPage.Xaml(Combo of Both Entrycell and Switches)

<TableView Intent="Data">
<TableRoot>
<TableSection Title="Our First Selection">
<TextCell Text="TextCell" Detail="TextCell Detail"/>
<EntryCell Label="Entery Label" Text="EntryCell Text"/>
<SwitchCell Text="SwitchCell Text"/>
<ImageCell Text="ImageCell Text" Detail="ImageCell Detail" ImageSource="icon.png"/>
</TableSection>
<TableSection Title="Our First Selection">
<TextCell Text="TextCell" Detail="TextCell Detail"/>
<EntryCell Label="Entery Label" Text="EntryCell Text"/>
<SwitchCell Text="SwitchCell Text"/>
<ImageCell Text="ImageCell Text" Detail="ImageCell Detail" ImageSource="XamarinLogo.png"/>
</TableSection>
</TableRoot>
</TableView>
view raw MainPage.xaml hosted with ❤ by GitHub
Step2:Holaa Nomore Steps

Xamarin Forms Switch Demo [Tutorial 33]

Step1:Create table root inside tableview
<TableRoot>
<TableSection>
<SwitchCell Text="On" On="True"/>
<SwitchCell Text="Off" On="False"/>
</TableSection>
</TableRoot>
view raw MainPage.xaml hosted with ❤ by GitHub
Step2:Holaaa.. No More Steps

Xamarin Forms Entry Cell [Tutorial 32]


Step1: Create a Table View Sample XAML Page That's All

<TableView>
<TableRoot>
<TableSection Title="Keyboards">
<EntryCell Label="Default" Placeholder="default"/>
<EntryCell Label="Chat" Placeholder="Chats" Keyboard="Chat"/>
<EntryCell Label="Email" Placeholder="sometin@xamarin.com" Keyboard="Email"/>
<EntryCell Label="Numberic" Placeholder="55" Keyboard="Numeric"/>
<EntryCell Label="Telephone" Placeholder="+977-------" Keyboard="Telephone"/>
<EntryCell Label="Text" Placeholder="text" Keyboard="Text"/>
<EntryCell Label=" Url" Placeholder="https://developer.xamarin.com" Keyboard="Url"/>
</TableSection>
<TableSection Title="States and Colors">
<EntryCell Label="Disabled" Placeholder="text" IsEnabled="False"/>
<EntryCell Label="Colorful" Placeholder="text" LabelColor="Red"/>
<EntryCell Label="Colorful + Disabled" Placeholder="text" IsEnabled="False" LabelColor="Blue"/>
</TableSection>
</TableRoot>
</TableView>
view raw MainPage.xaml hosted with ❤ by GitHub
Step2: Hola No More Steps

Xamarin Forms Label Borders [Tutorial 31]

Step1: We Have to Just Define our MainPage.xaml

<ContentPage.Resources>
<ResourceDictionary x:Name="AppDictionary">
<Color x:Key="BackgroundColor">#000000</Color>
<Color x:Key="BorderColor">#E1E1E1</Color>
<Style x:Key="InternalViewStyle" TargetType="ContentView">
<Setter Property="BackgroundColor" Value="{StaticResource BackgroundColor}"/>
<Setter Property="VerticalOptions" Value="Fill"/>
</Style>
<Style x:Key="BorderStyle" TargetType="ContentView">
<Setter Property="BackgroundColor" Value="{StaticResource BorderColor}"/>
<Setter Property="Padding" Value="3,1,1,3"/>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentView Padding="20" VerticalOptions="Center" HorizontalOptions="Center">
<ContentView Style="{StaticResource BorderStyle}" >
<ContentView Style="{StaticResource InternalViewStyle}">
<Label Text="I am Border 1!"
FontSize="20" TextColor="White"
HorizontalOptions="Center"></Label>
</ContentView>
</ContentView>
</ContentView>
view raw MainPage.xaml hosted with ❤ by GitHub
Step2:Holaaa No more Steps!!!

Friday, 3 November 2017

Xamarin Forms Stretched Background Image [Tutorial 30]


Step1: Insert IT Inside Your MainPage.xaml
<RelativeLayout>
<Image Source="http://wallsdesk.com/wp-content/uploads/2016/03/Eagle-Android-Wallpapers.jpg"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}"/>
<Grid RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}">
<Label Text="Eagle Feed On!!!!" VerticalOptions="Center" HorizontalOptions="Center" FontSize="30"/>
</Grid>
</RelativeLayout>
view raw MainPage.xaml hosted with ❤ by GitHub

Step2:There Are No more steps holaaa......!!!!

Xamarin Forms Fast Splash Screen[Tutorial 29]

Step 1 : At First Create a new Activity
namespace SplashScreen.Droid
{
[Activity(Theme ="@style/Theme.Splash",
MainLauncher = true,
NoHistory =true,
Icon ="@drawable/clap")]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
System.Threading.Thread.Sleep(500);
StartActivity(typeof(MainActivity));
}
}
}
view raw SplashActivity hosted with ❤ by GitHub
Step2: Disable the Main Launcher Screen From Main Activity
[Activity(Label = "SplashScreen", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
view raw MainActivity hosted with ❤ by GitHub
step3:You Have To Add Styles on styles.xml
<style name="Theme.Splash"
parent="android:Theme">
<item name="android:windowBackground">@drawable/clap</item>
<item name="andorid:windowNoTitle">true</item>
</style>
view raw styles.xml hosted with ❤ by GitHub
Step3:Please Make Sure If you had The Image Icon Same as Selected inside Your Drawable Folder
Step4:Holaa Our Steps Are Completed
Hey Guys if you are using Older Verson of Xamarin.Forms in which MainActivity is Inheriting from Forms Application Activity then you should do this in your styles:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.Splash"
parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/icon</item>
</style>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
view raw styles.xml hosted with ❤ by GitHub
Similarly Your Splash Activity will took like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace XFormsContosoCookbook.Droid
{
[Activity(Theme = "@style/Theme.Splash",
MainLauncher = true,
NoHistory = true,
Icon = "@drawable/icon")]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
System.Threading.Thread.Sleep(500);
StartActivity(typeof(MainActivity));
}
}
}
Your AndroidManifest will LookLike this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.xamarin.contosocookbook" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Xamarin Zero to Hero">
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
</application>
</manifest>