Всплывающее всплывающее окно VideoView (настройка правильной высоты) - PullRequest
0 голосов
/ 24 октября 2019

, поэтому я пытаюсь сделать всплывающее окно videoview.

У меня проблема в том, что высота всплывающего окна переносится на видео только через несколько секунд, когда видео действительно загружается. Это приводит к появлению огромного всплывающего окна сверху вниз в течение первых 5 секунд.

Этот код представляет экземпляр всплывающего окна.

        btnFloating = (Button)findViewById(R.id.btnFloating);
        relativeLayout = (RelativeLayout) findViewById(R.id.test2);

        LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
        popupView = layoutInflater.inflate(R.layout.popupvideo,null);
        popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
        ImageButton btnClose = (ImageButton)popupView.findViewById(R.id.btnClose);
        VideoView videoView = (VideoView) popupView.findViewById(R.id.videopopup);

        videoView.setVideoURI(Uri.parse(test2.this.videodata[f74n][3]));

        videoView.requestFocus();
        videoView.start();

        MediaController mMedia = new MediaController(context);
        mMedia.setAnchorView(videoView);
        videoView.setMediaController(mMedia);

        videoView.start();
        Button full = (Button)popupView.findViewById(R.id.full);

        btnClose.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                popupWindow.dismiss();
            }
        });

        full.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                FrameLayout.LayoutParams _rootLayoutParams = new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
                popupView.setLayoutParams(_rootLayoutParams);
   // This doesnt work, I need to use a FrameLayout here even though my layout got a RelativeLayout. It throws me an error when I use RelativeLayout.LayoutParams
            }
        });

XML:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    tools:ignore="Orientation">


    <VideoView
        android:id="@+id/videopopup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_centerInParent="true"
        android:focusable="false"
        android:focusableInTouchMode="false" />

    <ImageButton
        android:id="@+id/btnClose"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_alignParentRight="true"
        android:src="@drawable/redx"
        android:text="Close" />

    <Button
        android:layout_width="70dp"
        android:layout_height="50dp"
        android:layout_alignParentLeft="true"
        android:id="@+id/full"

        android:text="FullScreen" />
</RelativeLayout>
...