My video is not displayed in full screen on my Android device

Kim Strasser 1,321 Reputation points
2024-07-30T11:16:19.7533333+00:00

My video is not displayed in full screen on my Android device. There is always some empty space at the top and at the bottom. Is it possible to display it in full screen?

image0-2

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <mediamanager.platforms.android.video.VideoView
        android:id="@+id/exoplayerview_activity_video"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:layout_centerInParent="true" />
</RelativeLayout>

styles.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
     <style name="MainTheme" parent="MainTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MainTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!--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>
         <item name="android:windowFullscreen">true</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="android:colorPrimary">#2196F3</item>
        <!-- colorPrimaryDark is used for the status bar -->
        <item name="android:colorPrimaryDark">#1976D2</item>
        <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
        <item name="android:colorAccent">#FF4081</item>
        <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
         <item name="android:windowLightStatusBar">false</item>
        <item name="android:windowActionModeOverlay">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>
</resources>

VideoDialog.cs:

  public class VideoDialog : Dialog
  {
        public VideoDialog(Context context, int themeResId) : base(context, themeResId)
        {
        }
        protected override void OnCreate(Bundle? savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Window.RequestFeature(WindowFeatures.NoTitle);
            WindowCompat.SetDecorFitsSystemWindows(Window, false);
            WindowInsetsControllerCompat windowInsetsController = new WindowInsetsControllerCompat(Window, Window.DecorView);
            windowInsetsController.Hide(WindowInsetsCompat.Type.NavigationBars());
            windowInsetsController.SystemBarsBehavior = WindowInsetsControllerCompat.BehaviorShowTransientBarsBySwipe;
            View view = LayoutInflater.From(Context).Inflate(Resource.Layout.activity_main, null);
            SetContentView(view);
            Window.SetBackgroundDrawable(new ColorDrawable());
            Window.SetLayout(WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.MatchParent);
        }
  }


Game1.cs:

  public async void ShowTheVideo()
  {
      VideoDialog customDialog = new VideoDialog(activity1, Android.Resource.Style.ThemeDeviceDefaultDialogNoActionBar);
      customDialog.SetCancelable(false);
      customDialog.Show();
      await CrossMediaManager.Android.PlayFromResource(TestPluginMedia.Resource.Raw.Testvideo1.ToString());
      CrossMediaManager.Current.MediaItemFinished += (s, e) =>
      {
          customDialog.Cancel();
      };
   }
Developer technologies | .NET | .NET MAUI
Developer technologies | Visual Studio | Other
{count} votes

Accepted answer
  1. Anonymous
    2024-08-01T03:28:16.71+00:00

    Please remove Window.SetBackgroundDrawable(new ColorDrawable()); and change windowInsetsController.Hide(WindowInsetsCompat.Type.SystemBars());,

    And change Android.Resource.Style.ThemeDeviceDefaultDialogNoActionBar to Android.Resource.Style.ThemeBlackNoTitleBarFullScreen in the ShowTheVideo method

    I test your code in the Android Tablet emulator, it is working.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.