2013-06-12 3 views
0

Surface 뷰 위에 GLSurfaceView가 있어야합니다. GLSurface 뷰에는 렌더러가 있고 SurfaceView는 카메라 뷰입니다. 다음SurfaceView를 통한 GLSurfaceView

내 레이아웃

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

<RelativeLayout 
    android:id="@+id/root" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/title_bar" > 

    <Button 
     android:id="@+id/BTN_HOME_DEVICES" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:background="@drawable/btn_home" 
     android:text="@string/home_button" 
     android:textAppearance="?android:attr/textAppearanceMediumInverse" 
     android:textColor="@color/white" /> 

    <TextView 
     android:id="@+id/BANNER_HELP" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/BTN_HOME_HELP" 
     android:layout_alignBottom="@+id/BTN_HOME_HELP" 
     android:layout_centerHorizontal="true" 
     android:layout_centerInParent="true" 
     android:text="@string/auto_text" 
     android:textColor="@color/white" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="20sp" /> 

</RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/surface_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentRight="true" 
     android:focusable="true" > 

      <SurfaceView 
       android:id="@+id/cameraPreview" 
       android:layout_marginTop="120px" 
       android:layout_width="fill_parent" 
       android:layout_height="500dp" /> 

      <GLSurfaceView 
       android:id="@+id/glView" 
       android:layout_marginTop="120px" 
       android:layout_width="fill_parent" 
       android:layout_height="500dp" /> 



    </RelativeLayout> 

    <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:orientation="horizontal" 
       > 

       <Button 
        android:id="@+id/stopButton" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.20" 
        android:text="AR Call Stop" /> 

       <Button 
        android:id="@+id/startButton" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.20" 
        android:text="AR Call Start" /> 
      </LinearLayout> 
</RelativeLayout> 

입니다 그리고 내 활동에 내가 여기

GLSurfaceView glView = (GLSurfaceView) findViewById(R.id.glView); 
    glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); 
    glView.getHolder().setFormat(PixelFormat.TRANSLUCENT); 

    glView.setRenderer(new GLClearRenderer()); 

    setContentView(R.layout.auto_layout); 

아래 내 glView가 null로오고 같은 glsurface보기를 얻고있다. 이 동작을 올바른 방법으로 수행하는 방법은 무엇입니까?

답변

0

나는 XML 로직을 완전히 무시하고 addview를 통해 동적으로 요소를 추가함으로써 위의 문제를 해결했습니다.

그래서 나는 내가 원하는 것을 얻을 수있었습니다.

glView = new GLSurfaceView(this); 
glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); 
glView.getHolder().setFormat(PixelFormat.TRANSLUCENT); 
glView.setRenderer(new GLClearRenderer()); 

cameraPreview = new SurfaceView(this); 
addContentView(cameraPreview, new LayoutParams(cameraPreview.getLayoutParams().WRAP_CONTENT, 
          cameraPreview.getLayoutParams().WRAP_CONTENT)); 

addContentView(glView,new LayoutParams(cameraPreview.getLayoutParams().WRAP_CONTENT, 
        cameraPreview.getLayoutParams().WRAP_CONTENT));