简体   繁体   中英

Unable to display the ImageView in FrameLayout in android camera

As you can see in the layout below, I want to display both a ImageView and a GLSurfaceView . On the editor the ImageView is displayed within the framelayout , however, when I run my camera app , it simply displays the gl image in the center only, actually I want to display the imageView and the gl image together. Why is the ImageView with the id = "andme" not visible in real device ?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/cameraPreview"
        android:layout_width="match_parent"
        android:layout_height="505dp"
        android:layout_weight="1" >

        <android.opengl.GLSurfaceView
            android:id="@+id/GlViews"
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_gravity="center"
            android:background="#ff2594ff" />

        <ImageView
            android:id="@+id/target"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/andme" />
    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/background_material_dark"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/mytake"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/camera" />
    </LinearLayout>

</LinearLayout>

This is the part of the code from within the onCreate method . Is is causing the the only GLView image to show ? I simply want to show both the image and the glView image.

 setContentView(R.layout.activity_main);

    GLSurfaceView glSurfaceView = (GLSurfaceView)findViewById(R.id.GlViews);
    glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    // glSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
    glSurfaceView.setRenderer(new GLCubeRender(this,0));
    // glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    glSurfaceView.setZOrderOnTop(true);

You can do something like this-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/cameraPreview"
        android:layout_width="match_parent"
        android:layout_height="550dp"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <android.opengl.GLSurfaceView
            android:id="@+id/GlViews"
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_gravity="center"
            android:background="#ffffff" />

        <ImageView
            android:id="@+id/target"
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_gravity="center"
            android:background="@drawable/ic_launcher" />
    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/cream_dark"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/mytake"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/ic_launcher" />
    </LinearLayout>

</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM