0

我正在设置一个有两个视图的框架布局——一个是 ImageView,另一个是相机预览。这是代码:

public void setUpCamera(){
    //Set cameraView as the camera preview class
    cameraView = new CameraPreview(getApplicationContext());
    //Set imageResult as an image
    imageResult = new ImageView(getApplicationContext());

    imageResult.setBackgroundColor(Color.GRAY);

    //Prime the frame and buttons from the xml file
    frameLayout = (FrameLayout) findViewById(R.id.camera_preview);
    snapPhoto = (Button) findViewById(R.id.button_capture);

    //Add both camera preview and the snapped picture to the FrameLayout in the xml file 
    frameLayout.addView(imageResult);
    frameLayout.addView(cameraView);

    frameLayout.bringChildToFront(imageResult);

现在我的问题是是否可以将cameraView“隐形”添加到FrameLayout中?这是一件小事,但是在设置相机时,您会在通过bringChildToFront 方法将图像带到前台之前获得相机预览模式的闪光。

任何想法将不胜感激!

4

1 回答 1

0

你是追求setVisibility(View.GONE)还是setVisibility(View.INVISIBLE)

GONE 调整您的布局,就好像视图没有完全丢失一样,INVISIBLE 保持任何间距。

于 2012-11-27T21:58:02.320 回答