Example usage for android.view SurfaceView setZOrderMediaOverlay

List of usage examples for android.view SurfaceView setZOrderMediaOverlay

Introduction

In this page you can find the example usage for android.view SurfaceView setZOrderMediaOverlay.

Prototype

public void setZOrderMediaOverlay(boolean isMediaOverlay) 

Source Link

Document

Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself).

Usage

From source file:com.sim2dial.dialer.VideoCallFragment.java

private void fixZOrder(SurfaceView video, SurfaceView preview) {
    video.setZOrderOnTop(false);//from  w  ww. j  a v  a2 s .com
    preview.setZOrderOnTop(true);
    preview.setZOrderMediaOverlay(true); // Needed to be able to display control layout over
}

From source file:org.artoolkit.ar.unity.UnityARPlayerActivity.java

@Override
protected void onResume() {
    Log.i(TAG, "onResume()");

    super.onResume();

    ///*from  w w  w.  j a v  a  2 s  .c  o m*/
    // Wrap the Unity application's view and the camera preview in a FrameLayout;
    //

    //View focusView = getCurrentFocus(); // Save the focus, in case we inadvertently change it.
    //Log.i(TAG, "Focus view is " + focusView.toString() + ".");

    ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
    unityView = (ViewGroup) decorView.getChildAt(0);
    if (unityView == null) {
        Log.e(TAG, "Error: Could not find top view.");
        return;
    }
    //Log.i(TAG, "Top view is " + unityView.toString() + ".");

    // Create a placeholder for us to insert the camera preview capture object to the
    // view hierarchy.
    previewInserter = new FrameLayout(this);
    decorView.removeView(unityView); // We must remove the root view from its parent before we can add it somewhere else.
    decorView.addView(previewInserter);

    //focusView.requestFocus(); // Restore focus.

    // Create the camera preview.
    previewView = new CameraSurface(this);
    previewInserter.addView(previewView, new LayoutParams(128, 128));

    // Now add Unity view back in.
    // In order to ensure that Unity's view covers the camera preview each time onResume
    // is called, find the SurfaceView inside the Unity view hierachy, and
    // set the media overlay mode on it. Add the Unity view AFTER adding the previewView.
    SurfaceView sv = findSurfaceView(unityView);
    if (sv == null) {
        Log.w(TAG, "No SurfaceView found in Unity view hierarchy.");
    } else {
        Log.i(TAG, "Found SurfaceView " + sv.toString() + ".");
        sv.setZOrderMediaOverlay(true);
    }
    previewInserter.addView(unityView);
}

From source file:org.mozilla.gecko.GeckoApp.java

void addPluginView(final View view, final int x, final int y, final int w, final int h, final String metadata) {
    mMainHandler.post(new Runnable() {
        public void run() {
            PluginLayoutParams lp;/*from   w ww .  j  a va  2s.c  om*/

            Tabs tabs = Tabs.getInstance();
            Tab tab = tabs.getSelectedTab();

            if (tab == null)
                return;

            ViewportMetrics targetViewport = mLayerController.getViewportMetrics();
            ViewportMetrics pluginViewport;

            try {
                JSONObject viewportObject = new JSONObject(metadata);
                pluginViewport = new ViewportMetrics(viewportObject);
            } catch (JSONException e) {
                Log.e(LOGTAG, "Bad viewport metadata: ", e);
                return;
            }

            if (mPluginContainer.indexOfChild(view) == -1) {
                lp = new PluginLayoutParams(x, y, w, h, pluginViewport);

                view.setWillNotDraw(false);
                if (view instanceof SurfaceView) {
                    SurfaceView sview = (SurfaceView) view;

                    sview.setZOrderOnTop(false);
                    sview.setZOrderMediaOverlay(true);
                }

                mPluginContainer.addView(view, lp);
                tab.addPluginView(view);
            } else {
                lp = (PluginLayoutParams) view.getLayoutParams();
                lp.reset(x, y, w, h, pluginViewport);
                lp.reposition(targetViewport);
                try {
                    mPluginContainer.updateViewLayout(view, lp);
                    view.setVisibility(View.VISIBLE);
                } catch (IllegalArgumentException e) {
                    Log.i(LOGTAG, "e:" + e);
                    // it can be the case where we
                    // get an update before the view
                    // is actually attached.
                }
            }
        }
    });
}