Android layout with multiple views

Hi all,

Our app uses a webview alongside the gl_surface_view that OF extends. When switching between them, I noticed that input from the keyboard no longer fires the callback as the focus is lost from the GLview.

I tried all kinds of things – from adjusting view hierarchy (in main_layout.xml) to making the gl_surface transparent and moving it to the front, but in the end, what I needed was quite simple.

In the OfAndroidWindow.java file, we set the gl surface as focusable on touch. This is done as follows:

public OFGLSurfaceView(Context context,AttributeSet attributes) {
    ...
    this.setFocusableInTouchMode(true);
    ...
}

My main_layout.xml looks as follows:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">

<cc.openframeworks.OFGLSurfaceView android:id="@+id/of_gl_surface"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="visible" />

<WebView
    android:id="@+id/appView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="gone" />

</RelativeLayout>

When the app is done loading, the webview fires a callback asking to be set visible. When we have to do GL stuff, the webview requests itself be set to ‘gone’. This works quite well.

Just wanted to share this in-case others doing similar stuff run into the keyboard issue.

m.