public async Task FlyoutItemsRendererWhenFlyoutBehaviorStartsAsLocked() { SetupBuilder(); var shell = await CreateShellAsync(shell => { shell.CurrentItem = new FlyoutItem() { Items = { new ContentPage() }, Title = "Flyout Item" }; shell.FlyoutBehavior = FlyoutBehavior.Locked; }); await CreateHandlerAndAddToWindow <ShellRenderer>(shell, async (handler) => { await Task.Delay(1000); IShellContext shellContext = handler; DrawerLayout dl = shellContext.CurrentDrawerLayout; var flyout = dl.GetChildAt(0); RecyclerViewContainer flyoutContainer = null; if (dl.GetChildAt(1) is ViewGroup vg1 && vg1.GetChildAt(0) is RecyclerViewContainer rvc) { flyoutContainer = rvc; } _ = flyoutContainer ?? throw new Exception("Unable to locate RecyclerViewContainer"); Assert.True(flyoutContainer.MeasuredWidth > 0); Assert.True(flyoutContainer.MeasuredHeight > 0); }); }
private void MainScreenView_BackPressed(object sender, System.ComponentModel.CancelEventArgs e) { try { if (_drawerLayout.IsDrawerOpen(_drawerLayout.GetChildAt(1))) { _drawerLayout.CloseDrawers(); e.Cancel = true; } } catch { } }
RecyclerViewContainer GetFlyoutMenuReyclerView(ShellRenderer shellRenderer) { IShellContext shellContext = shellRenderer; DrawerLayout dl = shellContext.CurrentDrawerLayout; var flyout = dl.GetChildAt(0); RecyclerViewContainer flyoutContainer = null; if (dl.GetChildAt(1) is ViewGroup vg1 && vg1.GetChildAt(0) is RecyclerViewContainer rvc) { flyoutContainer = rvc; } return(flyoutContainer ?? throw new Exception("RecyclerView not found")); }
/** * Android4.4以上的状态栏着色(针对于DrawerLayout) * 注: * 1.如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性,尤其是DrawerLayout的fitsSystemWindows属性 * 2.可以版本判断在5.0以上不调用该方法,使用系统自带 * * @param activity Activity对象 * @param drawerLayout DrawerLayout对象 * @param statusBarColor 状态栏颜色 * @param alpha 透明栏透明度[0.0-1.0] */ public static void TintStatusBarForDrawer(Activity activity, DrawerLayout drawerLayout, int statusBarColor, float alpha) { if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat) { return; } Window window = activity.Window; //.getWindow(); ViewGroup decorView = (ViewGroup)window.DecorView; // (); ViewGroup drawContent = (ViewGroup)drawerLayout.GetChildAt(0); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { window.ClearFlags(WindowManagerFlags.TranslucentStatus); // WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); // WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.SetStatusBarColor(Color.Transparent); drawerLayout.SetStatusBarBackgroundColor(statusBarColor); int systemUiVisibility = (int)window.DecorView.SystemUiVisibility; // getDecorView().getSystemUiVisibility(); systemUiVisibility |= (int)SystemUiFlags.Fullscreen; // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; systemUiVisibility |= (int)SystemUiFlags.LayoutStable; // View.SYSTEM_UI_FLAG_LAYOUT_STABLE; window.DecorView.SystemUiVisibility = (StatusBarVisibility)systemUiVisibility; // getDecorView().setSystemUiVisibility(systemUiVisibility); } else { window.AddFlags(WindowManagerFlags.TranslucentStatus);// WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } SetStatusBar(decorView, statusBarColor, true, true); SetTranslucentView(decorView, alpha); drawerLayout.SetFitsSystemWindows(false); drawContent.SetFitsSystemWindows(true); ViewGroup drawer = (ViewGroup)drawerLayout.GetChildAt(1); drawer.SetFitsSystemWindows(false); }