Using android.view.SurfaceView with a camera on part of the screen

后端 未结 3 731
清酒与你
清酒与你 2020-12-08 23:54

I trying to put together an Android app that will take a picture and process it in some way. I\'d like the layout to be similar to Google Goggles. Meaning, camera preview

3条回答
  •  醉梦人生
    2020-12-09 00:29

    If I am not missing something, you cannot just use SurfaceView as is. You need a derived class of your own. I usually create this view programmatically, and give it the full screen. But you can cover parts of it with other views, including buttons:

     setContentView(new CameraView());
     View mainscreen = getLayoutInflater().inflate(R.layout.mainscreen, null, false);
     ViewGroup.LayoutParams generalLayoutParam = new ViewGroup.LayoutParams(
                        ViewGroup.LayoutParams.FILL_PARENT,
                        ViewGroup.LayoutParams.FILL_PARENT);
     addContentView(mainscreen, generalLayoutParam);
    

提交回复
热议问题