我正在尝试制作视频播放器,即Exoplayer全屏按下Click Click但不幸的是,由于播放器仅覆盖屏幕的一半,我无法这样做。
那里的任何人都可以帮助我。提前致谢
player.xml
<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代码:
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());
}
}
答案 0 :(得分:0)
您的exoplayer位于FrameLayout内,其固定高度为200dp。如果将match_parent
作为exoplayer的高度属性,则表示填充其直接父级的高度,在本例中为200dp FrameLayout。
解决此问题的一种方法是将exoplayer父级的高度更改为match_parent
。但由于布局没有最佳结构,因此您需要调整很多,保持相同的布局。我建议您阅读the following link on simple linear layout design以便更好地理解。