我正在使用此库https://github.com/dm77/ZBarScanner
如何自定义扫描仪框架的尺寸?
protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState);
if(!isCameraAvailable()) {
// Cancel request if there is no rear-facing camera.
cancelRequest();
return;
}
// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mAutoFocusHandler = new Handler();
// Create and configure the ImageScanner;
setupScanner();
// Create a RelativeLayout container that will hold a SurfaceView,
// and set it as the content of our activity.
mPreview = new CameraPreview(this, this, autoFocusCB);
setContentView(mPreview);
}
答案 0 :(得分:1)
你可以在FrameLayout中包装所有内容:
mPreview = new CameraPreview(this, this, autoFocusCB);
//Create a FrameLyout to hold some views
FrameLayout layout = new FrameLayout(this);
FrameLayout.LayoutParams layoutparams=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
layout.setLayoutParams(layoutparams);
//Example of a toolbar view to add
Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar_general, layout, false);
layout.addView(mPreview);//Add your CameraPreview
layout.addView(bar);//<----Add the example toolbar
//layout.addView(imageOverlay1);//<----This is where you'll add more views
//layout.addView(imageOverlay2);
setContentView(layout);
希望这有帮助。