Вот как это работает, чтобы включить полноэкранный режим с exoplayer,
В портретном режиме макет имеет вид exoplayer, охватывающий половину области экрана с другими видами, например, с текстовым представлением, кнопкой и имеет отдельный макет дляпейзаж с видом exoplayer, совпадающим с родителем и устанавливающим другие виды как пропавшие.
Портрет:
<android.support.constraint.ConstraintLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary_light"
tools:context=".ui.main.ViewRecipeStepFragment"
>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/ep_video_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
app:layout_constraintBottom_toTopOf="@+id/horizontalHalf"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<android.support.constraint.Guideline
android:id="@+id/horizontalHalf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/recipe_step_instruction"
app:layout_constraintGuide_percent="0.5"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="256dp"/>
<TextView
android:id="@+id/recipe_step_instruction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_marginBottom="8dp"
android:textAlignment="center"
android:textColor="@color/colorPrimaryDark"
android:textSize="18sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/horizontalHalf"
tools:text="Instructions"
/>
</android.support.constraint.ConstraintLayout>
Чтобы получить лучший опыт в портретной ориентации, вы можете скрыть системные элементы управления, используя что-то вроде этого (это может скрыть приложениебары), (вы можете вызвать это в onCreate () или onResume () действия)
@SuppressLint("InlinedApi")
private void hideSystemUi() {
playerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
Наконец, в ландшафтном режиме обновите макет до чего-то похожего,
Landscape:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.ViewRecipeStepFragment"
android:background="@color/primary_light"
>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/ep_video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent"
/>
</android.support.constraint.ConstraintLayout>