全屏视频播放器 - 导航栏后面的mediacontroller

zok*_*oki 15 android fullscreen android-videoview

我的mediacontroller有一个问题,它隐藏在导航栏后面(ICS上的软导航键).首先是OK(第一张图片),但是当第一次隐藏导航栏时,mediacontroller被调整大小以适应屏幕(正确),但是当再次出现导航栏时(第二张图片)不会调整大小.广告也被移到后面(隐藏屏幕截图).

如果我理解文档正确,fitSystemWindows应该负责调整大小.但它不起作用.

我怎样才能做到这一点?谢谢你的帮助.

我正在Galaxy Nexus上测试这个.

XML布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/playerLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animateLayoutChanges="true"
android:background="@color/black" >
<mynamespace.BKDVideoView
    android:id="@+id/videoview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"/>
<mynamespace.SubtitleTextView
    android:id="@+id/subtitleText"
    style="@style/SubtitleOverlayText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:layout_marginBottom="30dp"
    android:gravity="center"
    android:visibility="gone"
    android:fitsSystemWindows="true"
    android:animateLayoutChanges="true"/>
<FrameLayout
    android:id="@+id/adLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|right"
    android:fitsSystemWindows="true"
    android:animateLayoutChanges="true"/>
<FrameLayout
    android:id="@+id/videoMediaControllerHolder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:animateLayoutChanges="true"/>
Run Code Online (Sandbox Code Playgroud)

BKDVideoView是来自VideoView的GrepCode的副本,带有一些自定义.我为MediaController做了同样的事情.在MediaController中,我正在调用这样的隐藏:

int newVis = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_STABLE;
    if (!visible)
    {
        newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    // mSystemUiHolder -> FrameLayout (playerLayout)
    mSystemUiHolder.setSystemUiVisibility(newVis);
Run Code Online (Sandbox Code Playgroud)

什么时候没事 当它被覆盖

更新:如果您遇到同样的问题,请在接受的答案中查看评论.对于需要全屏使用sammyboy代码的视图.感谢两者.对不起,我需要太多时间搞清楚这一点并且无法给你积分:(

小智 5

这是系统问题.某些设备fill_parent或match_parent实体具有完全屏幕尺寸,并且无法识别系统宽度和高度.我建议:以编程方式为视图提供一个整数值.(计算系统条宽度和高度).并从屏幕大小中删除sb的宽度或高度(横向或纵向模式),并将此值设置为视图.

这里是如何获得屏幕尺寸等的答案

  • 我对此进行了一些调查.android:fitsSystemWindows仅在活动不是全屏时才有效; 在这里我有一个问题.在这种情况下,唯一的解决方案是设置programmaticaly宽度和高度并设置重力顶部(如你所说).对不起,我不能再给你点数了:( (3认同)