Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Use OnWindowFocusChange on Dialog Fragment

Xammy10Xammy10 Member ✭✭✭

I want to hide the status bar and bottom navigation bar of my fragment, I already did it on my activities, but I having a trouble on my Fragment. I use OnWindowFocusChange but I don't know how it works on fragments.

Thanks in advance :)


  • BillyLiuBillyLiu Member, Xamarin Team Xamurai


    Do you want to pop up a Dialog Fragment without status bar and bottom navigation bar?
    Could you post some related code?

  • Xammy10Xammy10 Member ✭✭✭

    Yes sir, that is my goal

    if (hasFocus)
    var uiOpTions =
    SystemUiFlags.HideNavigation |
    SystemUiFlags.LayoutHideNavigation |
    SystemUiFlags.LayoutFullscreen |
    SystemUiFlags.Fullscreen |
    SystemUiFlags.LayoutStable |
    Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOpTions;

    public override void OnWindowFocusChanged(bool hasFocus)

    This is working on Android activity, but as I said, I Idk how to use the OnWindowFocus on Fragmenrs

  • BillyLiuBillyLiu Member, Xamarin Team Xamurai


    You could set a theme to your Dialog.
    For example:

            Dialog dialog = new Dialog(this, Android.Resource.Style.ThemeLightNoTitleBarFullScreen);

    Or you could also try to change your activity theme:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <!-- Customize your theme here. -->
      <item name="colorPrimary">@color/colorPrimary</item>
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
      <item name="colorAccent">@color/colorAccent</item>
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowActionBar">false</item>
      <item name="android:windowFullscreen">true</item>
      <item name="android:windowContentOverlay">@null</item>
  • Xammy10Xammy10 Member ✭✭✭

    I did't answer my question, But I already solve my problem, thanks for the cooperation @BillyLiu :)

Sign In or Register to comment.