Saratsin.MvxOverlay.Android
1.0.0
dotnet add package Saratsin.MvxOverlay.Android --version 1.0.0
NuGet\Install-Package Saratsin.MvxOverlay.Android -Version 1.0.0
<PackageReference Include="Saratsin.MvxOverlay.Android" Version="1.0.0" />
paket add Saratsin.MvxOverlay.Android --version 1.0.0
#r "nuget: Saratsin.MvxOverlay.Android, 1.0.0"
// Install Saratsin.MvxOverlay.Android as a Cake Addin #addin nuget:?package=Saratsin.MvxOverlay.Android&version=1.0.0 // Install Saratsin.MvxOverlay.Android as a Cake Tool #tool nuget:?package=Saratsin.MvxOverlay.Android&version=1.0.0
MvxOverlay.Android
MvvmCross plugin for creating overlay views and show/close it with NavigationService
Getting Started
First of all, make sure you really need such kind of stuff, system overlays are very uncommon thing for apps and it's always better to use Activities or Fragments. Also if you're sure, then welcome
Prerequisites
Things you need:
- Xamarin.Android project
- MvvmCross (6.0 or higher)
Installing
First of all, add an overlay permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Before showing app overlay, you can check if your app has the overlay permissions (by default it disabled).
using System;
using MvvmCross.Plugin.Overlay.Platforms.Android.Services;
...
var overlayPermissionIsEnabled = OverlayPermissionService.Instance.CanDrawOverlays;
var overlayPermissionIsOrBecomeEnabled = await OverlayPermissionService.Instance.TryEnablePermissionIfDisabled(timeout: TimeSpan.FromMinutes(1), toastHintText: "Looks like we have no permissions :(");
If you won't do it, plugin will ask it by itself anyway.
Overlay Example
Android view implementation
public class ExampleOverlay : MvxOverlay<ExampleViewModel>
{
public ExampleOverlay(Context context) : base(context)
{
}
public override View CreateAndSetViewBindings()
{
var button = new Button(Context)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
};
var set = this.CreateBindingSet<ExampleOverlay, ExampleViewModel>();
set.Bind(button).For(v => v.Text).To(vm => vm.ButtonText);
set.Bind(button).For(nameof(View.Click)).To(vm => vm.ButtonClickedCommand);
set.Bind(button).For(nameof(View.LongClick)).To(vm => vm.ConnectButtonLongClickedCommand);
set.Apply();
return button;
}
public override OverlayLocationParams CreateLocationParams()
{
return new OverlayLocationParams(
gravity: GravityFlags.CenterHorizontal | GravityFlags.Top,
y: 50
);
}
}
ViewModel showing (inside the core project)
await Mvx.Resolve<IMvxNavigationService>().Navigate<ExampleViewModel>().ConfigureAwait(false);
Authors
- Taras Shevchuk - Initial work - Saratsin
License
This project is licensed under the MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
MonoAndroid | monoandroid81 is compatible. |
-
MonoAndroid 8.1
- MvvmCross (>= 6.0.1)
- MvvmCross.Droid.Support.Core.UI (>= 6.0.1)
- MvvmCross.Droid.Support.Design (>= 6.0.1)
- MvvmCross.Droid.Support.Fragment (>= 6.0.1)
- MvvmCross.Droid.Support.V7.AppCompat (>= 6.0.1)
- Xamarin.Android.Arch.Core.Common (>= 1.0.0)
- Xamarin.Android.Arch.Lifecycle.Common (>= 1.0.3)
- Xamarin.Android.Arch.Lifecycle.Runtime (>= 1.0.3)
- Xamarin.Android.Support.Animated.Vector.Drawable (>= 27.0.2)
- Xamarin.Android.Support.Annotations (>= 27.0.2)
- Xamarin.Android.Support.Compat (>= 27.0.2)
- Xamarin.Android.Support.Core.UI (>= 27.0.2)
- Xamarin.Android.Support.Core.Utils (>= 27.0.2)
- Xamarin.Android.Support.Design (>= 27.0.2)
- Xamarin.Android.Support.Fragment (>= 27.0.2)
- Xamarin.Android.Support.Media.Compat (>= 27.0.2)
- Xamarin.Android.Support.Transition (>= 27.0.2)
- Xamarin.Android.Support.v4 (>= 27.0.2)
- Xamarin.Android.Support.v7.AppCompat (>= 27.0.2)
- Xamarin.Android.Support.v7.CardView (>= 27.0.2)
- Xamarin.Android.Support.v7.MediaRouter (>= 27.0.2)
- Xamarin.Android.Support.v7.Palette (>= 27.0.2)
- Xamarin.Android.Support.v7.RecyclerView (>= 27.0.2)
- Xamarin.Android.Support.Vector.Drawable (>= 27.0.2)
- Xamarin.Build.Download (>= 0.4.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 1,131 | 6/7/2018 |