Изменить вид видео на полный экран

Я знаю, что видел подобные вопросы, но я еще не нашел решения. У меня есть приложение для Android TV Box, которое начинается с воспроизведения видео в небольшом представлении, определенном в моем основном xml. Я хочу сделать просмотр полноэкранным. Я попытался установить высоту и ширину, используя что-то вроде

DisplayMetrics displayMetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
            int height = displayMetrics.heightPixels;
            int width = displayMetrics.widthPixels;
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
            video.setLayoutParams(params);

но независимо от того, что я установил ширину и высоту, размер просмотра видео не меняется, он перемещается по экрану, но это все. Я также видел в потоках упоминание о создании нового действия с новым макетом (полноэкранный режим) и передаче экземпляра просмотра видео, но я не знаю, как передать экземпляр. Мы будем очень благодарны за любую помощь в получении полноэкранного просмотра.

Изменить: размещение xml. В соответствии с запросом здесь представлена ​​часть xml, которая включает просмотр видео. Как показано, видео заключено в линейный макет, установленный в размер предварительного просмотра. Если щелкнуть, я хочу, чтобы видео занимало весь экран.

<?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:id="@+id/parentLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_gravity="center"
    tools:context="com.yaadspice.epgtv.Activity.MainActivity">


    <TextView
        android:id="@+id/dateview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="18dp"
        android:layout_marginTop="8dp"
        android:text="DATE"
        android:textColor="@color/lb_tv_white"
        android:textSize="20sp"
        app:layout_constraintBottom_toTopOf="@+id/view"
        app:layout_constraintEnd_toStartOf="@+id/desc"
        app:layout_constraintStart_toStartOf="@+id/imageView"
        app:layout_constraintTop_toBottomOf="@id/imageView" />

    <View
        android:id="@+id/view"
        android:layout_width="1200dp"
        android:layout_height="5dp"
        android:layout_gravity="center"
        android:background="#00008B"
        app:layout_constraintHorizontal_bias="0.428"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/videocontainer"/>


    <ImageView
        android:id="@+id/imageView"
        android:layout_width="250dp"
        android:layout_height="110dp"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginStart="8dp"
        android:adjustViewBounds="false"
        android:paddingLeft="2dp"
        android:paddingRight="2dp"
        android:paddingTop="2dp"
        android:scaleType="fitXY"
        android:src="@drawable/overhanglogoplus"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <TextView
        android:id="@+id/holder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textSize="18sp"
        android:layout_marginTop="10dp"
        android:textColor="@color/lb_tv_white"
        android:text="HOLDER"
        app:layout_constraintStart_toEndOf="@id/videocontainer"/>

<LinearLayout
    android:id="@+id/videocontainer"
    android:layout_width="300dp"
    android:layout_height="175dp"
    android:layout_marginTop="2dp"
    android:orientation="horizontal"
    android:background="@android:color/transparent"
    app:layout_constraintStart_toEndOf="@id/desc"
    app:layout_constraintTop_toTopOf="parent" >



    <VideoView
        android:id="@+id/videoView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"/>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="60dp"
        app:layout_constraintStart_toStartOf="@id/videoView" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

person snowman    schedule 12.02.2018    source источник
comment
Почему бы просто не установить для VideoView значение MATCH_PARENT, а родителем будет корень дерева просмотра? Или вы могли бы опубликовать xml (включая просмотр видео), чтобы помочь другим понять, что вы сделали?   -  person sakiM    schedule 12.02.2018


Ответы (1)


Думаю, я перестарался. Используя приведенное ниже, я смог установить размер видео так, как мне было нужно.

LinearLayout container=(LinearLayout)findViewById(R.id.videocontainer);
ConstraintLayout.LayoutParams params= (ConstraintLayout.LayoutParams) container.getLayoutParams();
params.width=720;
            params.height=1280;
container.setLayoutParams(params);
person snowman    schedule 12.02.2018