2011-10-05 2 views
3

카메라보기를 보여주는 증강 현실 앱과 화면을 터치하여 회전 할 수있는 다각형이있는 GLSurfaceView가 있습니다. 내 애플 리케이션의 주요 레이아웃은 FrameLayout입니다. frameLayout에는 cameraView와 GLSurfaceView가 포함됩니다. 내 앱에는 cameraView를 오버레이하는 RelativeLayout에서 화면에 두 개의 버튼 (확대/축소)이 있습니다.내 카메라보기가 GLSurfaceView와 겹쳐져 있습니다 ...하지만 GLSurfaceView에 의해 오버레이되도록하려고합니다.

문제는 카메라보기가 다른 두 개의보기 (줌 버튼과 GLSurfaceView와 다각형이 겹침)가 문제이며, 화면에서 cameraView 만 볼 수 있다는 것입니다. 내 응용 프로그램의 기본 FrameLayout에서 cameraview를 제거하면 문제없이 GLSurfaceView와 줌 버튼을 볼 수 있습니다.

어떻게 해결할 수 있습니까? 나는 GLSurfaceView 줌 버튼으로 cameraView과 RelativeLayout의 오버레이 것을 필요로하는 GLSurfaceView ...

일부 업데이트를 오버레이 :

i는 안드로이드 2.2.2 (모토로라 드로이드)에서 완벽하게 작동하지만 것을 확인 1.5에서 2.1 버전으로 테스트하면 카메라보기가 다른보기와 중복됩니다.

내 앱의 contentview에서 뷰의 위치를 ​​반전하면 먼저 GLSurfaceView, 카메라와 마지막으로 버튼), 그리고 안드로이드 1.5에서 2.1로 작동하지만 ... 안드로이드 2에서 작동하지 않습니다. 2.2 이상 버전 !!! 내가

여기가 코드입니다 ...이 미친거야 :

public class ARLambo3DSample extends Activity { 
    private CustomCameraView cv=null; 
    private ImageView minus; 
    private ImageView plus; 
    private MySurfaceView mySurfaceView; 
    private boolean pressed=false; //algún boton de zoom pulsado 
    private boolean zoomIn=false; //si zoomIn=true entonces hace zoomIn y si es false hace zoomOut 
    private myThread t1; //Hilo que gestiona el zoomIn y el zoomOut 

    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     FrameLayout fl = new FrameLayout(this.getApplicationContext()); 
     cv = new CustomCameraView(this.getApplicationContext()); 
     RelativeLayout rl= new RelativeLayout(this.getApplicationContext()); 

     //turn off the window's title bar 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     //fullscreen 
     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     fl.addView(cv); 

     minus= new ImageView(getApplicationContext()); 
     minus.setImageResource(R.drawable.minus2); 
     rl.addView(minus); 

     plus= new ImageView(getApplicationContext()); 
     plus.setImageResource(R.drawable.plus2); 
     rl.addView(plus); 

     Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
     int w = display.getWidth(); 
     int h = display.getHeight(); 
     RelativeLayout.LayoutParams minusPosition = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
     RelativeLayout.LayoutParams plusPosition = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 

     minusPosition.leftMargin = (int)(w*0.77); 
     minusPosition.topMargin = (int)(h*0.80); //0.66 si no es fullscreen 
     minus.setLayoutParams(minusPosition); 

     plusPosition.leftMargin = (int)(w*0.88); 
     plusPosition.topMargin = (int)(h*0.80); 
     plus.setLayoutParams(plusPosition); 

     mySurfaceView = new MySurfaceView(this); 

     setContentView(fl); 

     plus.setClickable(true); //esto es necesario para poder gestionar cuando el boton se presiona y se suelta 
     minus.setClickable(true); //esto es necesario para poder gestionar cuando el boton se presiona y se suelta 

     minus.setOnTouchListener(new OnTouchListener() { 
      public boolean onTouch(View v, MotionEvent event) 
      { 
       switch(event.getAction()) 
       { 
        case MotionEvent.ACTION_DOWN: //boton presionado 
         zoomIn=false; 
         pressed=true; 
         break; 
        case MotionEvent.ACTION_UP: //boton se suelta 
         pressed=false; 
         break; 
       } 
       return false; 
      } 
     }); 
     plus.setOnTouchListener(new OnTouchListener() { 
      public boolean onTouch(View v, MotionEvent event) 
      { 
       switch(event.getAction()) 
       { 
        case MotionEvent.ACTION_DOWN: //boton presionado 
         zoomIn=true; 
         pressed=true;   
         break; 
        case MotionEvent.ACTION_UP: //boton se suelta 
         pressed=false; 
         break; 
       } 
       return false; 
      } 
     }); 

     t1= new myThread(); 
     t1.start(); 

     fl.addView(mySurfaceView); 
     fl.addView(rl); 

    } 
    protected void onResume() { 
     super.onResume(); 
     mySurfaceView.onResume(); 
    } 
    protected void onPause() { 
     super.onPause(); 
     mySurfaceView.onPause(); 
    } 
} 

답변

관련 문제