private FrameworkElement GetNativeSplashScreen(SplashScreen splashScreen) { try { var infoPlistPath = NSBundle.MainBundle.PathForResource("Info", "plist"); var infoPlistDictionary = new NSDictionary(infoPlistPath); var storyboardName = infoPlistDictionary["UILaunchStoryboardName"].ToString(); var storyboard = UIKit.UIStoryboard.FromName(storyboardName, null); var launchScreenViewController = storyboard.InstantiateInitialViewController(); var launchScreenView = launchScreenViewController.View; // We use a Border to ensure proper layout var element = new Border { Child = VisualTreeHelper.AdaptNative(launchScreenView), // We set a background to prevent touches from going through Background = SolidColorBrushHelper.Transparent }; return(element); } catch (Exception e) { typeof(ExtendedSplashScreen).Log().LogError(0, e, "Error while getting native splash screen."); return(null); } }
/// <summary> /// Add a native view to a <see cref="UIElementCollection"/>. It will be wrapped in a <see cref="FrameworkElement"/>-derived container to satisfy the type constraints of <see cref="UIElementCollection"/>. /// </summary> /// <remarks>This method is present to support collection initializer syntax for native views.</remarks> public static void Add(this UIElementCollection uiElementCollection, _View view) { if (uiElementCollection is null) { throw new ArgumentNullException(nameof(uiElementCollection)); } if (view is UIElement uiElement) { uiElementCollection.Add(uiElement); } var wrapper = VisualTreeHelper.AdaptNative(view); uiElementCollection.Add(wrapper); }
private FrameworkElement GetNativeSplashScreen(SplashScreen splashScreen) { try { var activity = ContextHelper.Current as Activity; // Get the theme's windowBackground (which we use as splash screen) var attribute = new Android.Util.TypedValue(); activity?.Theme.ResolveAttribute(Android.Resource.Attribute.WindowBackground, attribute, true); var windowBackgroundResourceId = attribute.ResourceId; // Get the splash screen size var splashScreenSize = GetSplashScreenSize(activity); // Create the splash screen surface var splashView = new Android.Views.View(activity); splashView.SetBackgroundResource(attribute.ResourceId); // We use a Canvas to ensure it's clipped but not resized (important when device has soft-keys) var element = new Canvas { // We set a background to prevent touches from going through Background = SolidColorBrushHelper.Transparent, // We use a Border to ensure proper layout Children = { new Border() { Width = splashScreenSize.Width, Height = splashScreenSize.Height, Child = VisualTreeHelper.AdaptNative(splashView), } }, }; return(element); } catch (Exception e) { typeof(ExtendedSplashScreen).Log().LogError(0, e, "Error while getting native splash screen."); return(null); } }
private void SetVideoSurface(IVideoSurface videoSurface) { this.Child = VisualTreeHelper.AdaptNative(videoSurface as SurfaceView); }