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

Kim Strasser 896 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();
      };
   }
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,900 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,244 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,491 Reputation points Microsoft Vendor
    2024-07-31T08:47:43.2333333+00:00

    Hello,

    Please change Android.Resource.Style.ThemeDeviceDefaultDialogNoActionBar to Android.Resource.Style.ThemeBlackNoTitleBarFullScreen in the ShowTheVideo method like following code.

    VideoDialog customDialog = new VideoDialog(activity1, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen);
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.