I already tried asking this question at Relative layout Coding, but that first attempt was not very clear.
I would like to create a relative layout over GLSurfaceView but the layout must look like this:
<RelativeLayout
android:id="@+id/View1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@raw/gi"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/b1" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:src="@drawable/b2" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView2"
android:src="@drawable/b3" />
</RelativeLayout>
However, if I code it like they say in the answers it works but the images are still put on top of each other. (I used the getId functions to addrules)
So I’m thinking of adding the whole xml file and work that way but any time I load an xml the app stops. Here’s most of the code:
public class HelloWorld extends Activity {
...
protected void onCreate(Bundle savedInstanceState) {
....
opengl = new GLSurfaceView(getApplication());
opengl.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(opengl);
addContentView(findViewById(R.id.View1), new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT));
Bear in mind that without the last call to addContentView the app works.
It looks like I’m gonna answer my own question.
instead of addcontentview i added the following
and as such I succeded in adding a whole xml file above the glsurface view.
But I am wondering now on how to get an id of each child in r.layout.gi. Let’s say I want to change a picture of R.id.imageView1 ??????????????
Does Anybody know how to do this with the current code?