SurfaceView визуализируется вне макета - PullRequest
0 голосов
/ 11 декабря 2018

Я создаю всплывающее всплывающее окно с видом на поверхность следующим образом: mFloatingView = LayoutInflater.from (contextWeak.get ()). Inflate (R.layout.layout_floating_widget, null);

    int type;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
    } else {
        type = WindowManager.LayoutParams.TYPE_TOAST;
    }

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            type,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    //Specify the view position
    params.gravity = Gravity.LEFT | Gravity.CENTER;        //Initially view will be added to top-left corner
    params.x = 0;
    params.y = 0;

    //Add the view to the window
    mWindowManager = (WindowManager) contextWeak.get().getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(mFloatingView, params);

    localVideoView = mFloatingView.findViewById(R.id.local_gl_surface_view);
    remoteVideoView = mFloatingView.findViewById(R.id.remote_gl_surface_view);
    localVideoView.setZOrderOnTop(true);
    remoteVideoView.setZOrderOnTop(true);

И xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    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">

    <!--Root container-->
    <RelativeLayout
        android:id="@+id/root_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:ignore="UselessParent">

        <!--View while view is collapsed-->
        <RelativeLayout
            android:id="@+id/collapse_view"
            android:layout_width="wrap_content"
            android:visibility="visible"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="#ccc">

            <!--Icon of floating widget -->
            <LinearLayout
                android:id="@+id/video"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <org.webrtc.SurfaceViewRenderer
                    android:id="@+id/remote_gl_surface_view"
                    android:layout_width="150dp"
                    android:layout_height="100dp" />

                <org.webrtc.SurfaceViewRenderer
                    android:id="@+id/local_gl_surface_view"
                    android:layout_width="150dp"
                    android:layout_height="100dp" />

            </LinearLayout>

            <!--Close button-->
            <ImageView
                android:id="@+id/close_btn"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:src="@drawable/ic_close"
                tools:ignore="ContentDescription"
                android:layout_toEndOf="@id/video"/>
        </RelativeLayout>
    </RelativeLayout>
</FrameLayout>

На Android 9 он правильно отображается, и я могу перетащить его с его содержимым, но на Android 6 я вижу, что SurfaceView отображается как измакет , и я могу перетащить его, но он перетаскивает всплывающее окно без SurfaceView.

Также в качестве бонуса появляется всплывающее окно с вырезанным пространством SurfaceView.Вот картинка: enter image description here

И видео, показывающее эту вещь: https://imgur.com/a/ChltcBT

Кто-нибудь знает, как добиться правильного поведения?

...