作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用这个库,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);
}
最佳答案
您可以将所有内容包装在 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);
希望这对您有所帮助。
关于android - 如何为 android ZBar QrCode 自定义 Scanner 框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30180680/
我是一名优秀的程序员,十分优秀!