首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Exoplayer全屏

Exoplayer全屏
EN

Stack Overflow用户
提问于 2018-06-07 15:50:36
回答 1查看 2.6K关注 0票数 1

我试图让视频播放器,即Exoplayer到全屏幕按钮点击,但不幸的是,我不能这样做,因为播放器只覆盖一半的屏幕。

附上玩家在景观模式下的外观截图:

任何能帮我的人。提前感谢

player.xml

代码语言:javascript
复制
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
  <ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.4"
            android:orientation="vertical"
            android:background="#FFFFFF"
            android:id="@+id/name">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:id="@+id/textholder">
              <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="This is a Dummy text to implement Scroll View in this application"
                    android:textColor="#424242"
                    android:textSize="50sp"
                    android:textStyle="bold"
                    android:id="@+id/text"
                   />
            </LinearLayout>
       </LinearLayout>
        <FrameLayout
            android:id="@+id/main_media_frame"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="#000000">

            <com.google.android.exoplayer2.ui.PlayerView
                android:id="@+id/player_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="fill" >
            </com.google.android.exoplayer2.ui.PlayerView>
        </FrameLayout>
        <LinearLayout
            android:id="@+id/videoDetailsLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.52"
            android:orientation="vertical"
            android:background="#FFFFFF">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:id="@+id/vd">
                <TextView
                    android:id="@+id/VideoName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="Big Buck Bunny"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="10dp"
                android:orientation="vertical"
                android:id="@+id/videoDetailsLayoutd">
                <TextView
                    android:id="@+id/vast_tag_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="Vast Tags"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    />
                <TextView
                    android:id="@+id/vast_tags"
                    android:layout_width="wrap_content"
                    android:layout_height="400dp"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

FullScreen代码:

代码语言:javascript
复制
private void openFullscreenDialog() {

    videoDetailsLayout.setVisibility(LinearLayout.GONE);
    vast_tags.setVisibility(LinearLayout.GONE);
    name.setVisibility(LinearLayout.GONE);

    ((ViewGroup) playerView.getParent()).setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN //hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);

    mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(PlayerActivity.this, R.drawable.ic_fullscreen_shrink));
    mExoPlayerFullscreen = true;
    //For explicitly changing the Orientation to Landscape
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    try {
        vast_tags.append("Fullscreen \n");
        videoEvents.playerStateChange(PlayerState.FULLSCREEN);
    } catch (Exception e) {
        Logger.d("Error is " + e.getMessage());
    }
}
EN

回答 1

Stack Overflow用户

发布于 2018-06-07 16:39:00

你的系外球员在一个固定高度为200 of的FrameLayout内。当您将match_parent作为系外玩家的高度attrib时,它意味着填充它的直系亲属的高度,在本例中是200 as。

解决这一问题的一种方法是将系外球员的父母的身高改为match_parent。但是,由于布局的结构不是最优的,所以您需要调整很多,保持相同的布局。我建议你给关于简单线性布局设计的下列链接读一读,以获得更好的理解。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50745472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档