2

我不确定这是否是完成此任务的正确方法,但我想要一个带有 GLSurfaceView 的弹出窗口。所以我创建了一个 dialogFragment 并在其 onCreateView 方法中返回我的 glSurfaceView:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mView = new mGLSurfaceView(this.getDialog().getContext());
    return mView;
}

当 DialogFragment 显示时,整个屏幕变暗,而不仅仅是背景。当我返回带有 TextView 的 LinearLayout 时,不会发生这种情况。

4

1 回答 1

3

This is because of the way GLSurfaceView works - the View part of GLSurfaceView is just a transparent container, and the rendering is done on Surface that sits below the Layout (and below the Layout for the Activity that has triggered the DialogFragment). Now when the DialogFragment is created, there is a "dimming layer" inserted between the DialogFragment and the parent Activity, to bring focus to the DialogFragment. This dimming layer ends up sitting between the transparent-View-part of GLSurfaceView, but above the rendering Surface, which explains why the entire screen appears to dim.

You can fix this by calling setZOrderOnTop(true) when you create your GLSurfaceView - this will force the rendering Surface to sit above all other views in the DialogFragment Layout, so above the dimming layer.

于 2016-06-17T00:48:28.747 回答