正如您在下面的layout
中看到的,我希望同时显示ImageView
和GLSurfaceView
。在编辑器上,ImageView
显示在framelayout
中,然而,当我运行camera
应用程序时,它只是在center
中显示gl图像,实际上我想同时显示imageView
和gl image
。为什么带有id = "andme"
的ImageView
在实际设备中不是visible
?
<?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>
这是onCreate方法中代码的一部分。是不是导致唯一的GLView图像显示?我只是想同时显示图像和glView图像。
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);
你可以做这样的事情-
<?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>